# AOJ ITP2_5_A: Sorting Pairs

# Python3 2018.6.24 bal4u



ps = []

n = int(eval(input()))

for i in range(n):

	x, y = list(map(int, input().split()))

	ps.append((x, y))

a = sorted(ps, key=lambda x:(x[0], x[1]))

for i in range(n): print((*a[i]))

# AOJ ITP2_5_A: Sorting Pairs

# Python3 2018.6.24 bal4u



ps = []

n = int(eval(input()))

for i in range(n):

	x, y = list(map(int, input().split()))

	ps.append((x, y))

ps.sort()

for i in ps: print((*i))

# AOJ ITP2_5_A: Sorting Pairs
# Python3 2018.6.24 bal4u
ps = []
n = int(eval(input()))
for i in range(n):
    x, y = list(map(int, input().split()))
    ps.append((x, y))
a = sorted(ps, key=lambda x: (x[0], x[1]))
for i in range(n):
    print((*a[i]))

# AOJ ITP2_5_A: Sorting Pairs
# Python3 2018.6.24 bal4u
ps = []
n = int(eval(input()))
for i in range(n):
    x, y = list(map(int, input().split()))
    ps.append((x, y))
ps.sort()
for i in ps:
    print((*i))

-a = sorted(ps, key=lambda x: (x[0], x[1])) -for i in range(n): -    print((*a[i])) +ps.sort() +for i in ps: +    print((*i))