On a plane are *n* points (*x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub>) with integer coordinates between 0 and 10<sup class="upper-index">6</sup>. The distance between the two points with numbers *a* and *b* is said to be the following value: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/03274f8c977ad3feb5d9f6ede91c69bcaef04972.png" style="max-width: 100.0%;max-height: 100.0%;"/> (the distance calculated by such formula is called Manhattan distance).

We call a hamiltonian path to be some permutation *p*<sub class="lower-index">*i*</sub> of numbers from 1 to *n*. We say that the length of this path is value <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/2872e932e7cab8f5f7a9c718441f7534261ed638.png" style="max-width: 100.0%;max-height: 100.0%;"/>.

Find some hamiltonian path with a length of no more than 25 × 10<sup class="upper-index">8</sup>. Note that you do not have to minimize the path length.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">6</sup>).

The *i* + 1-th line contains the coordinates of the *i*-th point: *x*<sub class="lower-index">*i*</sub> and *y*<sub class="lower-index">*i*</sub> (0 ≤ *x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>).

It is guaranteed that no two points coincide.

def dist(p1, p2):
	return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])


n = int(input())

pnts = []
for i in range(n):
	x,y = [int(i) for i in input().split(" ")]
	pnts.append([x,y,i])



# print(pnts)
pnts_xy = sorted(pnts, key=lambda p: (p[0],p[1]))
# print(pnts_xy)

str_list = []
for p in pnts_xy:
	str_list.append(str(p[2]) + " ")
print(''.join(str_list))


# count = 0
# for i in range(n-1):
	# count += dist(pnts_xy[i], pnts_x[i+1])
# for i in range(n):
	# print(pnts_xy[i][2]+1, end=' ')


# if(count <= 25*(10**8)):
# 	for i in range(n):
# 		print(pnts_x[i][2]+1, end=' ')
# else:
# 	pnts_y = sorted(pnts, key=lambda p: p[1])
# 	# count = 0
# 	# for i in range(n-1):
# 		# count += dist(pnts_y[i], pnts_y[i+1])

# 	for i in range(n):
# 		print(pnts_y[i][2]+1, end=' ')
  	     			     	   	      		