from sys import stdin def sortBy2 input return input int stdin readlin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
from sys import stdin
def sortBy2(input):
return input[2]
n = int(stdin.readline().strip())
points = []
for i in range(n):
point = stdin.readline().strip().split(" ")
x = int(point[0])
y = int(point[1])
dist = x ** 2 + y ** 2
points.append((x, y, dist))
points.sort(key=sortBy2)
for i in points:
print(str(i[0]) + " " + str(i[1]))