import sys
num_count = int(input())
data_list = list()
for _ in range(num_count):
x, y = [int(x) for x in sys.stdin.readline().split(' ')]
data_list.append((x, y))
data_list.sort(key=lambda x: (x[0], x[1]))
for result in data_list:
print(f"{result[0]} {result[1]}")
import sys
n = int(input())
array = []
for _ in range(n):
x, y = map(int, sys.stdin.readline().split(' '))
array.append((x, y))
array = sorted(array)
for i in array:
print(i[0], i[1])