City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the numbers of the roads that form them.

Sand roads have long been recognized out of date, so the decision was made to asphalt them. To do this, a team of workers was hired and a schedule of work was made, according to which the intersections should be asphalted.

Road repairs are planned for n^2 days. On the i-th day of the team arrives at the i-th intersection in the list and if none of the two roads that form the intersection were already asphalted they asphalt both roads. Otherwise, the team leaves the intersection, without doing anything with the roads.

According to the schedule of road works tell in which days at least one road will be asphalted.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 50) — the number of vertical and horizontal roads in the city. 

Next n^2 lines contain the order of intersections in the schedule. The i-th of them contains two numbers h_{i}, v_{i} (1 ≤ h_{i}, v_{i} ≤ n), separated by a space, and meaning that the intersection that goes i-th in the timetable is at the intersection of the h_{i}-th horizontal and v_{i}-th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.


-----Output-----

In the single line print the numbers of the days when road works will be in progress in ascending order. The days are numbered starting from 1.


-----Examples-----
Input
2
1 1
1 2
2 1
2 2

Output
1 4 

Input
1
1 1

Output
1 



-----Note-----

In the sample the brigade acts like that:  On the first day the brigade comes to the intersection of the 1-st horizontal and the 1-st vertical road. As none of them has been asphalted, the workers asphalt the 1-st vertical and the 1-st horizontal road;  On the second day the brigade of the workers comes to the intersection of the 1-st horizontal and the 2-nd vertical road. The 2-nd vertical road hasn't been asphalted, but as the 1-st horizontal road has been asphalted on the first day, the workers leave and do not asphalt anything;  On the third day the brigade of the workers come to the intersection of the 2-nd horizontal and the 1-st vertical road. The 2-nd horizontal road hasn't been asphalted but as the 1-st vertical road has been asphalted on the first day, the workers leave and do not asphalt anything;  On the fourth day the brigade come to the intersection formed by the intersection of the 2-nd horizontal and 2-nd vertical road. As none of them has been asphalted, the workers asphalt the 2-nd vertical and the 2-nd horizontal road.

Difficulty: EASY

Solutions:
import sys
n = int(input())
vert = [False for i in range(n)]
gor = [False for i in range(n)]
for i in range(n ** 2):
	(x, y) = [int(i) - 1 for i in input().split()]
	if not vert[x] and (not gor[y]):
		vert[x] = True
		gor[y] = True
		print(i + 1, end=' ')
print()


n = int(input())
(hp, vp) = ([False] * (n + 1), [False] * (n + 1))
for i in range(1, n ** 2 + 1):
	(hi, vi) = map(int, input().split())
	if not hp[hi] and (not vp[vi]):
		hp[hi] = vp[vi] = True
		print(i, end=' ')


(X, Y) = ([], [])
for i in range(int(input()) ** 2):
	(x, y) = map(int, input().split())
	if x not in X and y not in Y:
		print(i + 1, end=' ')
		X.append(x)
		Y.append(y)


n = int(input())
hused = []
yused = []
for x in range(n * n):
	if x == 0:
		a = list(map(int, input().split()))
		print(1, end=' ')
		hused.append(a[0])
		yused.append(a[1])
	else:
		a = list(map(int, input().split()))
		if hused.count(a[0]) == 0 and yused.count(a[1]) == 0:
			hused.append(a[0])
			yused.append(a[1])
			print(x + 1, end=' ')


n = int(input())
x = []
y = []
for i in range(n ** 2):
	u = [int(i) for i in input().split()]
	if u[0] not in x and u[1] not in y:
		x.append(u[0])
		y.append(u[1])
		print(i + 1, end=' ')


n = int(input())
A = [0 for i in range(n)]
B = [0 for i in range(n)]
day = 1
result = []
for i in range(n ** 2):
	(nowA, nowB) = [int(i) for i in input().split()]
	if A[nowA - 1] == 0 and B[nowB - 1] == 0:
		result.append(day)
		A[nowA - 1] = 1
		B[nowB - 1] = 1
	day += 1
for i in result:
	print(i, end=' ')


N = int(input())
paintH = set()
paintV = set()
d = 0
res = []
for i in range(N):
	for j in range(N):
		d += 1
		(h, v) = list(map(int, input().split()))
		if h not in paintH and v not in paintV:
			paintH.add(h)
			paintV.add(v)
			res.append(str(d))
print(' '.join(res))


n = int(input())
ys = [False for i in range(n)]
xs = [False for i in range(n)]
res = []
for i in range(1, n * n + 1):
	(x, y) = map(int, input().split(' ')[:2])
	x -= 1
	y -= 1
	if not ys[y] and (not xs[x]):
		res.append(i)
		ys[y] = True
		xs[x] = True
print(*res)


from sys import stdin
from sys import stdout
n = int(stdin.readline())
ax = [0 for i in range(51)]
by = [0 for i in range(51)]
for i in range(0, n ** 2):
	(x, y) = map(int, stdin.readline().split())
	if ax[x] == 0 and by[y] == 0:
		ax[x] = 1
		by[y] = 1
		stdout.write(str(i + 1) + ' ')


k = int(input())
(H, V, answer) = ([], [], [])
for i in range(k * k):
	(h, v) = map(int, input().split())
	if h not in H and v not in V:
		H.append(h)
		V.append(v)
		answer.append(i + 1)
print(*answer)


n = int(input())
horiz = [0] * n
vert = [0] * n
realDays = [False] * n ** 2
for i in range(0, n ** 2):
	line = [int(n) for n in input().split()]
	if horiz[line[0] - 1] == 0 and vert[line[1] - 1] == 0:
		horiz[line[0] - 1] = 1
		vert[line[1] - 1] = 1
		realDays[i] = True
out = ''
for i in range(0, len(realDays)):
	if realDays[i]:
		out += str(i + 1) + ' '
print(out)


n = int(input())
x = [False] * (n + 1)
y = [False] * (n + 1)
a = []
for i in range(1, n ** 2 + 1):
	(h, v) = map(int, input().split())
	if not x[h] and (not y[v]):
		a.append(i)
		x[h] = True
		y[v] = True
print(*a)


import time
(COL, ROW, LEN) = (1000, 1000, 26)
matrix = [[0] * COL for i in range(ROW)]
arr = [0] * LEN
direction = ((0, -1), (-1, 0), (0, 1), (1, 0))

class Pair:

	def __init__(self, x, y):
		self.x = x
		self.y = y

def timer(func, *pargs, **kargs):
	start = time.time()
	func(*pargs, **kargs)
	return time.time() - start

def test(a):
	answer = 0
	for value in a:
		if value >= 0:
			answer += value
	return answer
n = int(input())
ls = list()
matrix = [[0] * n for i in range(n)]
for i in range(n * n):
	(x, y) = map(int, input().split())
	if matrix[x - 1][y - 1] == 0:
		for j in range(n):
			matrix[x - 1][j] = 1
			matrix[j][y - 1] = 1
		ls.append(i + 1)
print(' '.join(map(str, ls)))


n = int(input())
doneH = []
doneV = []
sch = []
days = []
for i in range(n * n):
	line = input().split(' ')
	sch.append([line[0], line[1]])
for i in range(n * n):
	if sch[i][0] not in doneH and sch[i][1] not in doneV:
		doneH.append(sch[i][0])
		doneV.append(sch[i][1])
		days.append(str(i + 1))
	if len(doneH) == n:
		break
print(' '.join(days))


def main():
	n = int(input())
	x = [0] * n
	y = [0] * n
	for day in range(n * n):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		if x[a] == 0 and y[b] == 0:
			x[a] = 1
			y[b] = 1
			print(day + 1, end=' ')
main()


n = int(input())
h_road = [0] * (n + 1)
v_road = [0] * (n + 1)
res = ''
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	if h_road[h] == 0 and v_road[v] == 0:
		h_road[h] = 1
		v_road[v] = 1
		res += str(i + 1) + ' '
print(res)


a = int(input())
gmat = set()
vmat = set()
mat = []
for i in range(a ** 2):
	s = input().split()[0:2]
	z = int(s[0])
	x = int(s[1])
	if not z in gmat:
		if not x in vmat:
			vmat.add(x)
			gmat.add(z)
			mat.append(i + 1)
for i in mat:
	print(i, end=' ')


n = int(input())
vRoad = []
hRoad = []
days = []
for i in range(0, n + 1):
	vRoad.append(0)
	hRoad.append(0)
intersections = n * n
for i in range(0, intersections):
	(a, b) = [int(x) for x in input().split()]
	if hRoad[a] == 0 and vRoad[b] == 0:
		hRoad[a] = 1
		vRoad[b] = 1
		days.append(i + 1)
for day in days:
	print(day, end=' ')


n = int(input())
asphaltedH = set()
asphaltedV = set()
days = []
for i in range(n * n):
	(h, v) = [int(i) for i in input().split()]
	if h not in asphaltedH and v not in asphaltedV:
		days.append(i + 1)
		asphaltedH.add(h)
		asphaltedV.add(v)
print(' '.join([str(i) for i in sorted(days)]))


n = int(input())
n = n * n
h = []
v = []
ans = []
for i in range(n):
	(a, b) = map(int, input().split())
	if a not in h and b not in v:
		h.append(a)
		v.append(b)
		ans.append(i + 1)
a = ' '.join((str(e) for e in ans))
print(a)


n = int(input())
horizontal = []
vertical = []
days = []
for x in range(n ** 2):
	string = input()
	numbers = string.split(' ')
	a = int(numbers[0])
	b = int(numbers[1])
	if not a in horizontal and (not b in vertical):
		horizontal.append(a)
		vertical.append(b)
		days.append(str(x + 1))
print(' '.join(days))


n = int(input())
rows = []
cols = []
for i in range(n ** 2):
	(h, v) = [int(i) for i in input().split()]
	if h not in rows and v not in cols:
		print(i + 1, end=' ')
		rows.append(h)
		cols.append(v)


gi = lambda : list(map(int, input().split(' ')))
(n,) = gi()
occLines = [0 for e in range(n + 1)]
occCols = occLines[:]
for k in range(n * n):
	line = gi()
	if not (occLines[line[0]] or occCols[line[1]]):
		print(k + 1, end=' ')
		occLines[line[0]] = occCols[line[1]] = 1


a = int(input())
t = {}
l = {}
s = ''
for j in range(a ** 2):
	(n, m) = (int(i) for i in input().split())
	if n not in t.keys() and m not in l.keys():
		s = s + str(j + 1) + ' '
		t[n] = 1
		l[m] = 1
print(s)


n = int(input())
sa = set()
sb = set()
l = []
for i in range(n * n):
	(a, b) = list(map(int, input().split()))
	if not a in sa and (not b in sb):
		l += [str(i + 1)]
		sa.add(a)
		sb.add(b)
print(' '.join(l))


import math
import os
import random
import re
import sys
import functools
from operator import itemgetter, attrgetter
from collections import Counter
Y = lambda : list(map(int, input().split()))
P = lambda : map(int, input().split())
N = lambda : int(input())
n = N()
(H, V) = (dict(), dict())
r = list()
n *= n
for i in range(n):
	(h, v) = P()
	if not (h in H.keys() or v in V.keys()):
		r.append(i + 1)
		H[h] = H.get(h, True)
		V[v] = V.get(v, True)
for i in r:
	print(i, end=' ')


n = int(input())
H = [False for i in range(n + 1)]
V = [False for i in range(n + 1)]
ans = []
for i in range(n ** 2):
	(h, v) = list(map(int, input().split()))
	if not H[h] and (not V[v]):
		H[h] = True
		V[v] = True
		ans.append(i + 1)
print(' '.join(map(str, ans)))


n = int(input())
h = [False for i in range(n + 1)]
v = [False for j in range(n + 1)]
for j in range(n * n):
	(hh, vv) = map(int, input().split())
	if {h[hh], v[vv]} == {False}:
		print(j + 1, end=' ')
		h[hh] = True
		v[vv] = True


n = int(input())
hor = [False] * n
ver = hor * 1
L = []
for xasre in range(n * n):
	(x, y) = [int(k) - 1 for k in input().split()]
	if not (hor[x] or ver[y]):
		L.append(str(xasre + 1))
		hor[x] = True
		ver[y] = True
print(' '.join(L))


n = int(input())
i = 0
hv = []
vv = []
ans = []
while i < n * n:
	(h, v) = map(int, input().split())
	if h not in hv and v not in vv:
		ans.append(i + 1)
		hv.append(h)
		vv.append(v)
	i += 1
for i in ans:
	print(i, end=' ')


n = int(input())
m = n ** 2
L = [list(map(int, input().split())) for _ in range(m)]
H = [0 for _ in range(n)]
V = [0 for _ in range(n)]
R = ''
for k in range(m):
	i = L[k][0] - 1
	j = L[k][1] - 1
	if H[i] == 0 and V[j] == 0:
		H[i] = 1
		V[j] = 1
		R = R + str(k + 1) + ' '
print(R)


n = int(input())
a = [False] * n
b = [False] * n
for i in range(n * n):
	(h, v) = map(int, input().split())
	h -= 1
	v -= 1
	if not a[h] and (not b[v]):
		a[h] = b[v] = True
		print(i + 1, end=' ')


from collections import Counter as CC
n = int(input())
(ans, h, v) = ([], [], [])
for i in range(0, n ** 2):
	(x, y) = list(map(int, input().split()))
	if x not in h and y not in v:
		ans.append(i + 1)
		h.append(x)
		v.append(y)
print(*ans)


n = int(input())
s = [set(), set()]
ans = ''
for i in range(n * n):
	t = [int(x) for x in input().split()]
	if t[0] not in s[0] and t[1] not in s[1]:
		ans += str(i + 1) + ' '
		s[0].add(t[0])
		s[1].add(t[1])
print(ans)


from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
d = defaultdict(int)
e = defaultdict(int)
for i in range(I() ** 2):
	(n, k) = M()
	if d[n] == 0 and e[k] == 0:
		print(i + 1, end=' ')
		d[n] = 1
		e[k] = 1


n = int(input())
lih = []
liv = []
ans = []
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	if h not in lih and v not in liv:
		ans.append(i + 1)
		liv.append(v)
		lih.append(h)
print(*ans)


n = int(input())
x = []
y = []
dates = []
for i in range(n * n):
	(a, b) = map(int, input().split())
	if a not in x and b not in y:
		x.append(a)
		y.append(b)
		dates.append(str(i + 1))
print(' '.join(dates))


x = int(input())
ls = []
for i in range(x ** 2):
	s = input().split()
	for i in range(len(s)):
		s[i] = int(s[i])
	ls.append(s)
row = [True] * (x + 1)
col = [True] * (x + 1)
ans = []
for i in range(x ** 2):
	if row[ls[i][0]] and col[ls[i][1]]:
		row[ls[i][0]] = False
		col[ls[i][1]] = False
		ans.append(i + 1)
for i in range(len(ans) - 1):
	print(ans[i], ' ', sep='', end='')
print(ans[len(ans) - 1])


n = int(input())
l = []
m = []
for i in range(n * n):
	(h, v) = map(int, input().split())
	if h not in l and v not in m:
		print(i + 1, end=' ')
		l.append(h)
		m.append(v)


import sys
num_roads = int(input())
if num_roads < 1 or num_roads > 50:
	sys.exit()
h_roads = []
v_roads = []
number_repair_days = []
for i in range(num_roads ** 2):
	name_intersection = input().split()
	if name_intersection[0] not in h_roads and name_intersection[1] not in v_roads:
		number_repair_days.append(i + 1)
		v_roads.append(name_intersection[1])
		h_roads.append(name_intersection[0])
for i in number_repair_days:
	print(i, end=' ')


n = int(input())
ch = set()
cv = set()
for i in range(n * n):
	(h, v) = map(int, input().split())
	if h in ch or v in cv:
		continue
	else:
		ch.add(h)
		cv.add(v)
		print(i + 1, end=' ')


seta = set()
setb = set()
n = int(input())
for i in range(n ** 2):
	(a, b) = [int(i) for i in input().split()]
	if a not in seta and b not in setb:
		print(i + 1, end=' ')
		seta.add(a)
		setb.add(b)


n = int(input())
h = [False for i in range(n)]
v = [False for i in range(n)]
z = []
for i in range(n * n):
	(a, b) = list(map(int, input().split()))
	a -= 1
	b -= 1
	if not h[a] and (not v[b]):
		z.append(i + 1)
		h[a] = True
		v[b] = True
print(*z)


n = int(input())
h = [False] * n
v = [False] * n
result = []
for i in range(n * n):
	(a, b) = list(map(int, input().split()))
	a -= 1
	b -= 1
	if not h[a] and (not v[b]):
		h[a] = v[b] = True
		result.append(i + 1)
print(' '.join(map(str, result)))


n = int(input())
roads = [[0] * n for _ in range(n)]
days = []
for j in range(n * n):
	sum_x = 0
	sum_y = 0
	work = input().split()
	for i in range(n):
		sum_x += roads[int(work[0]) - 1][i]
		sum_y += roads[i][int(work[1]) - 1]
	if sum_x == 0 and sum_y == 0:
		roads[int(work[0]) - 1][int(work[1]) - 1] += 1
		days.append(j + 1)
print(*days, sep=' ')


data = int(input())
vert = set([])
hor = set([])
result = []
for i in range(1, data * data + 1):
	(a, b) = map(int, input().split(' '))
	if a not in vert and b not in hor:
		result.append(i)
		vert.add(a)
		hor.add(b)
print(*result, sep=' ')


n = int(input())
roads = []
for i in range(n):
	roads.append([0] * n)
ans = []
for i in range(n ** 2):
	(r, c) = map(int, input().split())
	t = 0
	for j in range(n):
		t += roads[r - 1][j]
		t += roads[j][c - 1]
	if t == 0:
		ans.append(i + 1)
		roads[r - 1][c - 1] = 1
print(' '.join(map(str, ans)))


n = int(input())
s1 = []
s2 = []
k = 0
for i in range(n ** 2):
	k = 0
	st = [int(i) for i in input().split(' ')]
	if s1.count(st[0]) == 0 and s2.count(st[1]) == 0:
		print(i + 1, sep=' ', end=' ')
		s1.append(st[0])
		s2.append(st[1])


nroads = int(input())
schedule = []
for rd in range(nroads ** 2):
	schedule.append(input().split(' '))
vertical = [False for i in range(nroads)]
horizontal = vertical.copy()
inprogress = []
time = 0
for day in schedule:
	h = int(day[0]) - 1
	v = int(day[1]) - 1
	if not horizontal[h] and (not vertical[v]):
		horizontal[h] = True
		vertical[v] = True
		time += 1
		print(time, end=' ')
	else:
		time += 1
print()


n = int(input())
(hor_roads, ver_roads) = ([], [])
work_days = []
for i in range(n ** 2):
	(x, y) = (int(j) for j in input().split())
	if x not in hor_roads and y not in ver_roads:
		work_days.append(i + 1)
		hor_roads.append(x)
		ver_roads.append(y)
result = ''
for day in work_days:
	result += str(day) + ' '
print(result[:-1])


n = int(input())
li = [[0] * n for i in range(n)]
for i in range(n * n):
	(a, b) = [int(i) for i in input().split()]
	if li[a - 1][b - 1] == 0:
		for j in range(n):
			li[j][b - 1] = 1
			li[a - 1][j] = 1
		print(i + 1, end=' ')


n = int(input())
h = {i: 0 for i in range(1, n + 1)}
v = {i: 0 for i in range(1, n + 1)}
l = []
for i in range(1, n * n + 1):
	(a, b) = map(int, input().split())
	if h[a] == 0 and v[b] == 0:
		l.append(i)
		(h[a], v[b]) = (1, 1)
print(*l)


n = int(input())
h = [False] * n
v = [False] * n
d = []
for i in range(n * n):
	(hr, vr) = [int(k) for k in input().split()]
	if not h[hr - 1] and (not v[vr - 1]):
		h[hr - 1] = True
		v[vr - 1] = True
		d.append(i)
opt = ''
for i in d:
	opt += str(i + 1) + ' '
print(opt)


n = int(input())
s = [[0 for a in range(n)] for b in range(n)]
for i in range(n ** 2):
	(a, b) = [int(i) for i in input().split()]
	ac = 0
	for j in range(n):
		if s[a - 1][j] != 0 or s[j][b - 1] != 0:
			ac += 1
	if ac == 0:
		s[a - 1][b - 1] += 1
		print(i + 1, end=' ')


n = int(input())
ans = []
(aa, bb) = ([False] * 90, [False] * 90)
for i in range(1, n ** 2 + 1):
	(a, b) = map(int, input().split())
	if not aa[a] and (not bb[b]):
		ans.append(i)
		aa[a] = True
		bb[b] = True
print(' '.join(map(str, ans)))


(a, b) = ({0}, {0})
for i in range(int(input()) ** 2):
	(x, y) = map(int, input().split())
	if x not in a and y not in b:
		a |= {x}
		b |= {y}
		print(i + 1, end=' ')


n = int(input().strip())
garizontal = []
vertical = []
garizontal1 = []
vertical1 = []
otvet = []
for i in range(n ** 2):
	ll = list(map(int, input().split()))
	garizontal.append(ll[0])
	vertical.append(ll[1])
for i in range(n ** 2):
	if garizontal[i] not in garizontal1 and vertical[i] not in vertical1:
		garizontal1.append(garizontal[i])
		vertical1.append(vertical[i])
		otvet.append(str(i + 1))
print(' '.join(otvet))


f2 = lambda : map(int, input().split())
n = int(input())
ans = []
stx = set()
sty = set()
x = n * n
for i in range(x):
	(x, y) = f2()
	if x not in stx and y not in sty:
		stx.add(x)
		sty.add(y)
		ans.append(i + 1)
	else:
		continue
ans.sort()
print(*ans)


import time
n = int(input())
H = [0 for i in range(n)]
V = [0 for i in range(n)]
days = []
j = 1
for i in range(n * n):
	(h, v) = (int(i) for i in input().split())
	h -= 1
	v -= 1
	if H[h] == 0 and V[v] == 0:
		H[h] = 1
		V[v] = 1
		days.append(j)
	j += 1
start = time.time()
for i in days:
	print(i, end=' ')
print()
finish = time.time()


(h_asphalted, v_asphalted) = (set(), set())
for i in range(1, int(input()) ** 2 + 1):
	(h, v) = input().split()
	if h not in h_asphalted and v not in v_asphalted:
		h_asphalted.add(h)
		v_asphalted.add(v)
		print(i, end=' ')


n = int(input())
x = [0 for i in range(n + 1)]
y = [0 for i in range(n + 1)]
s = ''
for i in range(n ** 2):
	(x1, y1) = map(int, input().split())
	if x[x1] == 0 and y[y1] == 0:
		s += str(i + 1) + ' '
		x[x1] = 1
		y[y1] = 1
print(s)


n = int(input())
h1 = []
v1 = []
h = 0
v = 0
s = []
d = ''
for i in range(n * n):
	s = input().split()
	h = int(s[0])
	v = int(s[1])
	if h not in h1 and v not in v1:
		h1.append(h)
		v1.append(v)
		d += str(i + 1) + ' '
print(d)


n = int(input())
G = []
V = []
res = []
for i in range(n * n):
	(h, v) = map(int, input().split())
	if G.count(h) == 0 and V.count(v) == 0:
		G.append(h)
		V.append(v)
		res.append(i + 1)
print(*res)


n = int(input())
road1 = [0] * n
road2 = [0] * n
days = []
for i in range(n * n):
	(h, v) = map(int, input().split())
	h -= 1
	v -= 1
	if road1[h] == 0 and road2[v] == 0:
		days.append(i + 1)
		road1[h] = 1
		road2[v] = 1
for i in range(len(days)):
	print(days[i], end=' ')
print()


n = int(input())
a = [False for _ in range(n)]
b = [False for _ in range(n)]
ans = []
for day in range(n * n):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if not a[x] and (not b[y]):
		a[x] = True
		b[y] = True
		ans.append(day + 1)
print(' '.join(map(str, ans)))


n = int(input())
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
w = []
for k in range(n ** 2):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	if not (x[a] or y[b]):
		x[a] = 1
		y[b] = 1
		w.append(k + 1)
if len(w) == 1:
	print(w[0])
else:
	for u in w[:-1]:
		print(u, end=' ')
	print(w[-1])


import sys
n = int(input())
vlist = [0] * (n + 1)
hlist = [0] * (n + 1)
ans = []
for i in range(1, n * n + 1):
	(v, h) = map(int, sys.stdin.readline().split())
	if vlist[v] == 0 and hlist[h] == 0:
		ans.append(i)
		vlist[v] = 1
		hlist[h] = 1
print(' '.join([str(a) for a in ans]))


__author__ = 'yarsanich'
n = int(input(''))
h = []
v = []
for i in range(n * n):
	(x, y) = map(int, input('').split())
	if x not in h and y not in v:
		h.append(x)
		v.append(y)
		print(i + 1, end=' ')


days = []
takenRows = []
takenCols = []
for i in range(int(input().strip()) ** 2):
	(x, y) = map(int, input().strip().split())
	if x not in takenRows and y not in takenCols:
		takenCols.append(y)
		takenRows.append(x)
		days.append(i + 1)
print(*days)


n = int(input())
res = []
used = [False] * n
used1 = [False] * n
for i in range(n * n):
	(x, y) = [int(x) for x in input().split()]
	if used[x - 1] == False and used1[y - 1] == False:
		res.append(i + 1)
		used[x - 1] = True
		used1[y - 1] = True
print(*res)


n = int(input())
hh = [0] * n
vv = [0] * n
ret = []
for (i, (h, v)) in enumerate((map(int, input().split()) for _ in range(n * n))):
	if not hh[h - 1] and (not vv[v - 1]):
		ret.append(str(i + 1))
		hh[h - 1] = 1
		vv[v - 1] = 1
print(' '.join(ret))


n = int(input())
(a, b) = ([0, 0] * n, [0, 0] * n)
for i in range(n * n):
	(x, y) = map(int, input().split())
	if a[x] < 1 > b[y]:
		a[x] = b[y] = 1
		print(i + 1, end=' ')


def roads(lst):
	a = list()
	h = [0] * 55
	v = [0] * 55
	for elem in lst:
		if not h[elem[0]] and (not v[elem[1]]):
			a.append(lst.index(elem) + 1)
			(h[elem[0]], v[elem[1]]) = (1, 1)
	return a
n = int(input())
b = list()
for i in range(n * n):
	(hh, vv) = [int(j) for j in input().split()]
	b.append([hh, vv])
print(*roads(b))


n = int(input())
hor = []
ver = []
r = []
for i in range(n * n):
	(a, b) = map(int, input().split(' '))
	if a not in hor and b not in ver:
		r.append(i + 1)
		hor.append(a)
		ver.append(b)
print(' '.join(map(str, r)))


n = int(input())
r = [False] * n
l = [False] * n
c = ''
for i in range(n * n):
	(k, m) = [int(i) for i in input().split()]
	if not r[k - 1] and (not l[m - 1]):
		r[k - 1] = True
		l[m - 1] = True
		c += str(i + 1) + ' '
print(c)


n = int(input())
h = []
v = []
d = []
for i in range(n * n):
	(a, b) = map(int, input().split())
	if a not in h and b not in v:
		h.append(a)
		v.append(b)
		d.append(i + 1)
for i in d:
	print(i, end=' ')


n = int(input())
ans = []
doneH = set()
doneV = set()
for i in range(n ** 2):
	(m, n) = map(int, input().split())
	if m not in doneH and n not in doneV:
		ans.append(i + 1)
		doneH.add(m)
		doneV.add(n)
print(' '.join((str(x) for x in ans)))


n = int(input())
roads = [[False for _ in range(n)], [False for _ in range(n)]]
for i in range(n ** 2):
	(x, y) = map(int, input().split())
	if roads[0][x - 1] == False and roads[1][y - 1] == False:
		roads[0][x - 1] = True
		roads[1][y - 1] = True
		print(i + 1, end=' ')


n = int(input())
A = n * [False]
B = n * [False]
r = []
i = 1
for _ in range(n ** 2):
	(a, b) = map(int, input().split())
	if not A[a - 1] and (not B[b - 1]):
		A[a - 1] = True
		B[b - 1] = True
		r.append(str(i))
	i += 1
print(' '.join(r))


def main():
	n = int(input())
	asphalted_rows = [False for _ in range(n + 1)]
	asphalted_cols = [False for _ in range(n + 1)]
	result = []
	for i in range(1, n * n + 1):
		[row, col] = [int(_) for _ in input().split()]
		if asphalted_rows[row] or asphalted_cols[col]:
			pass
		else:
			asphalted_rows[row] = True
			asphalted_cols[col] = True
			result += [str(i)]
	print(' '.join(result))
main()


n = int(input())
he = set()
ve = set()
res = []
for i in range(1, n ** 2 + 1):
	(h, v) = map(int, input().split())
	if h not in he and v not in ve:
		he.add(h)
		ve.add(v)
		res.append(i)
print(' '.join(map(str, res)))


n = int(input())
horz = []
vert = []
for i in range(1, n ** 2 + 1):
	(h, v) = map(int, input().split())
	if h not in horz and v not in vert:
		horz.append(h)
		vert.append(v)
		print(i, end=' ')


n = int(input())
x_roads = list()
y_roads = list()
days = list()
for index in range(n * n):
	(x, y) = map(int, input().split())
	if not x in x_roads and (not y in y_roads):
		x_roads.append(x)
		y_roads.append(y)
		days.append(index + 1)
print(' '.join((str(e) for e in days)))


n = int(input())
ans = []
vertical = [0] * (n + 1)
horizontal = [0] * (n + 1)
for i in range(n * n):
	(x, y) = map(int, input().split())
	if not horizontal[x] and (not vertical[y]):
		horizontal[x] = 1
		vertical[y] = 1
		ans.append(i + 1)
print(' '.join(map(str, ans)))


n = int(input())
(x, y) = (dict(), dict())
o = list()
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	if not a in x and (not b in y):
		o.append(i + 1)
		x[a] = True
		y[b] = True
print(' '.join(list(map(str, o))))


n = int(input())
vis1 = [bool(False) for i in range(55)]
vis2 = [bool(False) for i in range(55)]
for i in range(n * n):
	(a, b) = map(int, input().split(' '))
	if not vis1[a] and (not vis2[b]):
		print(i + 1, end=' ')
		vis1[a] = True
		vis2[b] = True


roads = int(input())
intersections = []
days = ''
for r in range(roads * roads):
	intersections.append([int(x) for x in input().split()])
xaxis = []
yaxis = []
for i in range(len(intersections)):
	if not intersections[i][0] in xaxis and (not intersections[i][1] in yaxis):
		days = days + str(i + 1) + ' '
		xaxis.append(intersections[i][0])
		yaxis.append(intersections[i][1])
print(days[:-1])


(r, rr, res) = ([], [], [])
for i in range(int(input()) ** 2):
	(k, kk) = map(int, input().split())
	if k not in r and kk not in rr:
		r.append(k)
		rr.append(kk)
		res.append(i + 1)
print(*res)


from sys import stdin
n = int(stdin.readline())
horizontal_roads = [False] * n
vertical_roads = [False] * n
work_days = []
for i in range(n * n):
	(h, v) = (int(x) - 1 for x in stdin.readline().split())
	if not horizontal_roads[h] and (not vertical_roads[v]):
		work_days.append(i + 1)
		horizontal_roads[h] = True
		vertical_roads[v] = True
print(' '.join((str(x) for x in work_days)))


__author__ = 'suvasish'
n = int(input())
intersection_order = []
row_count = 0
asphalted_hori = []
asphalted_vert = []
for i in range(0, n * n):
	line = input()
	if line:
		intersection_order.append(line)
for row in range(0, len(intersection_order)):
	row_count += 1
	row_items = intersection_order[row].split(' ')
	hori = int(row_items[0])
	vert = int(row_items[1])
	if hori in asphalted_hori or vert in asphalted_vert:
		continue
	else:
		asphalted_hori.append(hori)
		asphalted_vert.append(vert)
		print(row_count, end=' ')


n = int(input())
l = []
for _ in range(n * n):
	l.append(list(map(int, input().split())))
done = []
done1 = []
day = []
for i in range(n * n):
	if l[i][0] not in done and l[i][1] not in done1:
		done.append(l[i][0])
		done1.append(l[i][1])
		day.append(i + 1)
print(*day, sep=' ')


n = int(input())
q = set()
w = set()
l = []
for i in range(n * n):
	(a, b) = map(int, input().split())
	if a in q or b in w:
		continue
	else:
		q.add(a)
		w.add(b)
		l.append(i + 1)
print(*l)


n = int(input())
S1 = []
S2 = []
S = []
for i in range(n * n):
	l = list(map(int, input().split()))
	z = 0
	for c in S1:
		if c == l[0]:
			z = 1
	for c in S2:
		if c == l[1]:
			z = 1
	if z != 1:
		S.append(str(i + 1))
		S1.append(l[0])
		S2.append(l[1])
print(' '.join(S))


n = int(input())
pairs = [[int(i) - 1 for i in input().split(' ')] for pair in range(n ** 2)]
vert = [0 for i in range(n)]
hori = [0 for i in range(n)]
days = []
day = 1
for pair in pairs:
	if vert[pair[0]] == 1 or hori[pair[1]] == 1:
		day += 1
		continue
	vert[pair[0]] = 1
	hori[pair[1]] = 1
	days.append(day)
	day += 1
print(' '.join([str(i) for i in days]))


n = int(input())
usedx = [False] * (n + 1)
usedy = [False] * (n + 1)
for i in range(1, n * n + 1):
	(x, y) = map(int, input().split())
	if not usedx[x] and (not usedy[y]):
		print(i, end=' ')
		usedx[x] = True
		usedy[y] = True


import sys
lines = iter(sys.stdin.read().split('\n'))
n = int(next(lines))
rows = [0] * (n + 1)
cols = [0] * (n + 1)
res = []
for i in range(n ** 2):
	(r, c) = list(map(int, next(lines).strip(' ').split(' ')))
	if rows[r] == 0 and cols[c] == 0:
		rows[r] = 1
		cols[c] = 1
		res.append(str(i + 1))
print(' '.join(res))


n = int(input())
hor = [0] * (n + 1)
ver = [0] * (n + 1)
ans = []
for i in range(1, n * n + 1):
	(a, b) = map(int, input().split())
	if hor[a] == 0 and ver[b] == 0:
		ans.append(i)
		hor[a] = 1
		ver[b] = 1
print(*ans)


n = int(input())
mas1 = [1] * (n + 1)
mas2 = [1] * (n + 1)
res = []
for i in range(n * n):
	(a, b) = map(int, input().split(' '))
	if mas1[a] and mas2[b]:
		(mas1[a], mas2[b]) = (0, 0)
		res.append(str(i + 1))
print(' '.join(res))


n = int(input())
a = [0] * (n + 1)
b = [0] * (n + 1)
ans = []
for i in range(1, n * n + 1):
	(x, y) = map(int, input().split())
	if a[x] + b[y] == 0:
		ans += [str(i)]
		a[x] = 1
		b[y] = 1
print(' '.join(ans))


n = int(input())
a = []
for i in range(n * n):
	a.append([])
for i in range(n * n):
	a[i] = list(map(int, input().split()))
hmark = [0] * (n + 1)
vmark = [0] * (n + 1)
ans = []
for i in range(n * n):
	if not hmark[a[i][0]] and (not vmark[a[i][1]]):
		hmark[a[i][0]] = 1
		vmark[a[i][1]] = 1
		ans.append(i + 1)
for i in range(len(ans)):
	print(ans[i], end=' ')


def get_result():
	n = int(input())
	asphalted_h = []
	asphalted_v = []
	working_days = []
	for i in range(n ** 2):
		(h, v) = [int(val) for val in input().split()]
		if not (h in asphalted_h or v in asphalted_v):
			asphalted_h.append(h)
			asphalted_v.append(v)
			working_days.append(str(i + 1))
	return ' '.join(working_days)
print(get_result())


n = int(input())
s = []
for _ in range(n * n):
	v = input().split()
	s.append((v[0], v[1]))
ph = set()
pv = set()
for i in range(1, n * n + 1):
	(sh, sv) = s[i - 1]
	if sh not in ph and sv not in pv:
		print(i, end=' ')
		ph.add(sh)
		pv.add(sv)


from collections import defaultdict
n = int(input())
d = defaultdict(set)
ans = []
for i in range(n * n):
	(a, b) = map(int, input().split())
	if a not in d['V'] and b not in d['H']:
		ans.append(i + 1)
		d['V'].add(a)
		d['H'].add(b)
print(*ans)


hm = int(input())
hm2 = hm * hm
rows = []
cols = []
lis = []
for i in range(1, hm + 1):
	rows.append(i)
	cols.append(i)
for i in range(1, hm2 + 1):
	(row, col) = input().split(' ')
	row = int(row)
	col = int(col)
	if row in rows and col in cols:
		lis.append(i)
		rows.remove(row)
		cols.remove(col)
print(*lis, sep=' ')


n = int(input())
hor = []
ver = []
ans = []
for i in range(1, n * n + 1):
	s = input().split()
	if s[0] not in hor and s[1] not in ver:
		ans.append(i)
		hor.append(s[0])
		ver.append(s[1])
for i in ans:
	print(i, end=' ')


n = int(input())
a = []
b = []
for i in range(1, n * n + 1):
	(x, y) = map(int, input().split())
	if x not in a and y not in b:
		print(i, end=' ')
		a.append(x)
		b.append(y)


t = int(input())
t1 = []
t2 = []
for i in range(t * t):
	(a, b) = map(int, input().split())
	if a in t1 or b in t2:
		continue
	else:
		t1.append(a)
		t2.append(b)
		print(i + 1, end=' ')


n = int(input())
hset = set()
vset = set()
answer = ''
for i in range(1, n * n + 1):
	(h, v) = (int(x) for x in input().split())
	if h not in hset and v not in vset:
		hset.add(h)
		vset.add(v)
		answer = answer + str(i) + ' '
print(answer)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from collections import deque
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().split(' ')))

def solve():
	n = int(input())
	hor = set()
	ver = set()
	for i in range(n * n):
		(x, y) = read()
		if not (x in hor or y in ver):
			print(i + 1, end=' ')
			hor.add(x)
			ver.add(y)
solve()


n = int(input())
row = [False] * (n + 1)
col = [False] * (n + 1)
ans = []
for i in range(n * n):
	(h, v) = map(int, input().split())
	if not (row[h] or col[v]):
		row[h] = True
		col[v] = True
		ans.append(i + 1)
print(' '.join(map(str, ans)))


N = int(input())
plan = list()
for i in range(N ** 2):
	plan.append([int(i) for i in input().split()])
(ver, her, progress) = (list(), list(), list())
day = 1
for item in plan:
	if item[0] not in ver and item[1] not in her:
		progress.append(str(day))
		ver.append(item[0])
		her.append(item[1])
	day += 1
print(' '.join(progress))


def main():
	n = int(input())
	(hh, vv, res) = ([True] * (n + 1), [True] * (n + 1), [])
	for i in range(1, n * n + 1):
		(h, v) = map(int, input().split())
		if hh[h] and vv[v]:
			hh[h] = vv[v] = False
			res.append(i)
	print(' '.join(map(str, res)))
main()


n = int(input())
l = [0] * n
d = []
for i in range(n * n):
	(a, b) = map(int, input().split())
	if l[a - 1] & 1 == 0 and l[b - 1] & 2 == 0:
		l[a - 1] = l[a - 1] | 1
		l[b - 1] = l[b - 1] | 2
		d.append(i + 1)
print(' '.join(map(str, d)))


n = int(input())
H = []
V = []
D = []
for i in range(1, n * n + 1):
	(a, b) = map(int, input().split())
	if a not in H and b not in V:
		H.append(a)
		V.append(b)
		D.append(i)
for x in D:
	print(x, end=' ')


n = int(input())
(v, h) = ([0] * (n + 1), [0] * (n + 1))
r = []
for i in range(n * n):
	[hi, vi] = list(map(int, input().split(' ')))
	if h[hi] + v[vi] == 0:
		(h[hi], v[vi]) = (1, 1)
		r.append(i + 1)
print(*r)


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def printARR(arr):
	for e in arr:
		print(e, end=' ')
	print()

def main():
	(visited_h, visited_v) = (set(), set())
	n = I()
	for i in range(n * n):
		(h, v) = M()
		if h not in visited_h and v not in visited_v:
			print(i + 1, end=' ')
			visited_v.add(v)
			visited_h.add(h)
tc = 1
for _ in range(tc):
	main()


n = int(input())
x = []
for el in range(n * n):
	inters = input()
	x.append([int(i) for i in inters.split()])
hor = [i + 1 for i in range(n)]
ver = [i + 1 for i in range(n)]
dates = []
day = 1
for i in x:
	if (i[0] in hor) & (i[1] in ver):
		dates.append(day)
		hor.remove(i[0])
		ver.remove(i[1])
	day += 1
for i in dates:
	print(i, end=' ')


n = int(input())
H = [False for i in range(n)]
V = [False for i in range(n)]
for i in range(n ** 2):
	(h, v) = [int(i) - 1 for i in input().split()]
	if not H[h] and (not V[v]):
		H[h] = True
		V[v] = True
		print(i + 1, end=' ')


class StdReader:

	def read_int(self):
		return int(self.read_string())

	def read_ints(self, sep=None):
		return [int(i) for i in self.read_strings(sep)]

	def read_float(self):
		return float(self.read_string())

	def read_floats(self, sep=None):
		return [float(i) for i in self.read_strings(sep)]

	def read_string(self):
		return input()

	def read_strings(self, sep=None):
		return self.read_string().split(sep)
reader = StdReader()

def main():
	n = reader.read_int()
	h_done = [False] * n
	v_done = [False] * n
	for i in range(n * n):
		(h, v) = reader.read_ints()
		h -= 1
		v -= 1
		if not h_done[h] and (not v_done[v]):
			print(i + 1, end=' ')
			h_done[h] = True
			v_done[v] = True
main()


n = int(input())
row = [False for i in range(n)]
col = [False for i in range(n)]
ans = []
for i in range(n ** 2):
	(u, v) = list(map(int, input().split()))
	u -= 1
	v -= 1
	if row[u] == False and col[v] == False:
		row[u] = True
		col[v] = True
		ans.append(i + 1)
print(*ans)


num = int(input())
x = []
y = []
resultList = []
for i in range(1, num + 1):
	x.append(i)
	y.append(i)
for i in range(num ** 2):
	(a, b) = map(int, input().split())
	if a in x and b in y:
		resultList.append(i + 1)
		x.remove(a)
		y.remove(b)
print(' '.join((str(s) for s in resultList)))


days = []
n = int(input())
taken_horizontal = []
taken_vertical = []
for day in range(1, n * n + 1):
	(h, v) = [int(x) for x in input().split()]
	if not h in taken_horizontal and (not v in taken_vertical):
		days.append(day)
		taken_horizontal.append(h)
		taken_vertical.append(v)
print(' '.join([str(x) for x in days]))


n = int(input())
res = ''
h = []
v = []
for i in range(1, n ** 2 + 1):
	crossroad = tuple(map(int, input().split(' ')))
	if not (crossroad[0] in h or crossroad[1] in v):
		h.append(crossroad[0])
		v.append(crossroad[1])
		res += str(i) + ' '
	else:
		continue
print(res.strip())


n = int(input())
rs = [0 for i in range(n + 1)]
cs = [0 for i in range(n + 1)]
s = ''
for i in range(n ** 2):
	(r, c) = list(map(int, input().split()))
	if rs[r] == 0 and cs[c] == 0:
		rs[r] = 1
		cs[c] = 1
		s += str(i + 1) + ' '
print(s)


import itertools, functools, math

def solve():
	n = int(input())
	rows = [False] * n
	cols = [False] * n
	days = []
	for i in range(1, n * n + 1):
		(r, c) = map(int, input().split())
		r -= 1
		c -= 1
		if not rows[r] and (not cols[c]):
			rows[r] = True
			cols[c] = True
			days.append(i)
	return days
print(*solve())


x = int(input()) ** 2
inter = [input().split() for i in range(x)]
token_0 = []
token_1 = []
days = []
for i in range(x):
	if inter[i][0] not in token_0 and inter[i][1] not in token_1:
		token_0.append(inter[i][0])
		token_1.append(inter[i][1])
		days.append(i + 1)
print(' '.join(map(str, sorted(days))))


n = int(input())
isetv = set()
isetg = set()
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	if a not in isetv and b not in isetg:
		isetv.add(a)
		isetg.add(b)
		print(i + 1, end=' ')


n = int(input())
ans = list()
row = [0] * n
col = [0] * n
for x in range(n ** 2):
	(i, j) = map(int, input().split())
	(i, j) = (i - 1, j - 1)
	if row[i] == 0 and col[j] == 0:
		row[i] += 1
		col[j] += 1
		ans.append(x + 1)
print(' '.join([str(x) for (i, x) in enumerate(ans)]))


n = int(input(''))
d1 = {}
d2 = {}
arr = []
for i in range(0, n * n):
	s = input('')
	a = s.split(' ')
	x = int(a[0])
	y = int(a[1])
	try:
		d1[x] = d1[x] + 1
	except:
		try:
			d2[y] = d2[y] + 1
		except:
			arr.append(str(i + 1))
			d1[x] = 1
			d2[y] = 1
print(' '.join(arr))


a = int(input())
b = []
c = []
d = []
for i in range(a ** 2):
	(*e,) = map(int, input().split())
	if e[0] in b or e[1] in c:
		continue
	else:
		d += [i + 1]
		b += [e[0]]
		c += [e[1]]
print(' '.join(map(str, d)))


ans = []
vis2 = [0 for i in range(1005)]
vis1 = [0 for i in range(1005)]
n = int(input())
for i in range(n * n):
	(a, b) = map(int, input().split(' '))
	if vis1[a] == vis2[b] and vis1[a] == 0:
		ans.append(i + 1)
		vis1[a] = vis2[b] = 1
print(*ans)


n = int(input())
a = []
b = []
for i in range(n):
	a.append(False)
for i in range(n):
	b.append(False)
for i in range(n * n):
	(x, y) = [int(x) for x in input().split()]
	if a[x - 1] == False and b[y - 1] == False:
		print(i + 1, end=' ')
		a[x - 1] = True
		b[y - 1] = True


n = int(input())
ans = []
h = [False] * n
v = [False] * n
for d in range(n * n):
	(i, j) = (int(x) - 1 for x in input().split())
	if not h[i] and (not v[j]):
		ans += [d]
		v[j] = True
		h[i] = True
print(' '.join([str(x + 1) for x in ans]))


n = int(input())
h = [0 for i in range(n + 1)]
v = [0 for i in range(n + 1)]
ans = []
for i in range(n * n):
	(x, y) = map(int, input().split())
	if h[x] == 0 and v[y] == 0:
		ans.append(i + 1)
		h[x] = 1
		v[y] = 1
print(*ans)


(n, l1, l2) = (int(input()), [], [])
for i in range(n * n):
	(x, y) = input().split()
	if x not in l1 and y not in l2:
		print(i + 1, end=' ')
		l1.append(x)
		l2.append(y)


R = lambda : list(map(int, input().split()))
n = int(input())
(l, k) = ([], [])
for i in range(n * n):
	(n, m) = R()
	if n not in l and m not in k:
		print(i + 1, end=' ')
		l.append(n)
		k.append(m)


n = int(input())
arr = list()
for i in range(n):
	arr.append([False] * n)
l = list()
k = 1
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	h -= 1
	v -= 1
	if not arr[h][v]:
		for j in range(n):
			arr[h][j] = True
			arr[j][v] = True
		l.append(k)
	k += 1
for i in l:
	print(i, end=' ')


a = int(input())
answer = ''
hpaved = []
vpaved = []
pavingDays = []
for i in range(0, a ** 2):
	(h, v) = map(int, input().split())
	if h not in hpaved and v not in vpaved:
		hpaved.append(h)
		vpaved.append(v)
		answer += str(i + 1) + ' '
print(answer)


N = int(input())
hs = set([])
vs = set([])
ans = []
for i in range(N ** 2):
	(h, v) = map(int, input().split())
	if h in hs or v in vs:
		continue
	hs.add(h)
	vs.add(v)
	ans.append(i + 1)
print(' '.join(map(str, ans)))


n = int(input())
done_h = set()
done_v = set()
days = []
for i in range(n * n):
	(h, v) = map(int, input().split(' '))
	if h not in done_h and v not in done_v:
		done_h.add(h)
		done_v.add(v)
		days.append(i + 1)
print(*days)


cases = int(input())
cases *= cases
xx = set()
yy = set()
ans = []
for (i, cs) in enumerate(range(cases), start=1):
	(x, y) = map(int, input().split())
	if x not in xx and y not in yy:
		xx.add(x)
		yy.add(y)
		ans.append(i)
print(*ans)


import itertools as ittls
from collections import Counter
from pprint import pprint as pprint
import re
import math

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
N = int(input())
maskrow = [0] * N
maskcol = [0] * N
res = []
for i in range(N * N):
	(x, y) = inputarray(lambda x: int(x) - 1)
	if maskrow[x] == 0 and maskcol[y] == 0:
		res.append(i)
		maskrow[x] = 1
		maskcol[y] = 1
print(' '.join(map(lambda x: str(x + 1), res)))


n = int(input())
h = [0] * n
v = [0] * n
days = []
for i in range(n ** 2):
	roads = [int(i) for i in input().split()]
	(j, k) = (roads[0] - 1, roads[1] - 1)
	if h[j] == 0 and v[k] == 0:
		h[j] = 1
		v[k] = 1
		days.append(str(i + 1))
print(' '.join(days))


n = int(input())
(x, y) = ([], [])
for i in range(1, n ** 2 + 1):
	(x1, y1) = map(int, input().split())
	if not x1 in x and (not y1 in y):
		x.append(x1)
		y.append(y1)
		print(i, end=' ')


n = int(input())
res = []
x = set()
y = set()
for i in range(n * n):
	(a, b) = map(int, input().split())
	if not (a in x or b in y):
		x.add(a)
		y.add(b)
		res.append(i + 1)
print(*res)


n = int(input())
inter = [[False] * n, [False] * n]
for i in range(n * n):
	(h, v) = input().split()
	hnum = int(h) - 1
	vnum = int(v) - 1
	if not inter[0][hnum] and (not inter[1][vnum]):
		inter[0][hnum] = True
		inter[1][vnum] = True
		print(i + 1, end=' ')


n = int(input())
h = []
v = []
for i in range(n * n):
	(horizontal, vertical) = map(int, input().split())
	if horizontal not in h and vertical not in v:
		h.append(horizontal)
		v.append(vertical)
		print(i + 1, end=' ')


n = int(input())
roads = [[int(j) for j in input().split()] for i in range(n ** 2)]
Horizontal = []
Vertical = []
Days = []
for i in range(0, n ** 2):
	if roads[i][0] not in Vertical and roads[i][1] not in Horizontal:
		Vertical.append(roads[i][0])
		Horizontal.append(roads[i][1])
		Days.append(i + 1)
for i in range(0, len(Days)):
	print(Days[i], end=' ')


n = int(input())
a = [0] * n * n
b = [0] * n * n
for i in range(n * n):
	(a[i], b[i]) = map(int, input().split())
h = list()
c = [int(i) for i in range(1, n + 1)]
d = [int(i) for i in range(1, n + 1)]
for i in range(n * n):
	if c[a[i] - 1] != 0 and d[b[i] - 1] != 0:
		h.append(i + 1)
		c[a[i] - 1] = d[b[i] - 1] = 0
for i in h:
	print(i, end=' ')


x = int(input())
us1 = [0] * (x + 1)
us2 = [0] * (x + 1)
l = []
for i in range(x ** 2):
	(a, b) = map(int, input().split(' '))
	if not us1[a] and (not us2[b]):
		us1[a] = 1
		us2[b] = 1
		l.append(i + 1)
print(' '.join(map(str, l)))


n = int(input().split()[0])
hb = [False for _ in range(n + 1)]
vb = hb[:]
days = ''
for i in range(n ** 2):
	s = input().split()
	(hi, vi) = (int(s[0]), int(s[1]))
	if not (hb[hi] or vb[vi]):
		(hb[hi], vb[vi]) = (True, True)
		days += ' ' + str(i + 1)
print(days[1:])


n = int(input())
z = []
z1 = []
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	z.append(h)
	z1.append(v)
z2 = []
z3 = []
z4 = []
for j in range(len(z)):
	if z[j] not in z2 and z1[j] not in z3:
		z2.append(z[j])
		z3.append(z1[j])
		z4.append(j + 1)
print(*z4)


n = int(input())
a = [[0 for i in range(n)] for j in range(n)]

def fillcol(a, x):
	for i in range(len(a)):
		a[i][x] = 1

def fillrow(a, y):
	for i in range(len(a)):
		a[y][i] = 1
mylist = list()
for i in range(n * n):
	(x, y) = list(map(int, input().split()))
	if a[y - 1][x - 1] == 0:
		mylist.append(i + 1)
		fillcol(a, x - 1)
		fillrow(a, y - 1)
print(' '.join([str(item) for item in mylist]))


n = int(input())
days = []
(H, V) = ([0 for j in range(n)], [0 for x in range(n)])
for i in range(1, n ** 2 + 1):
	(h, v) = map(int, input().split())
	if H[h - 1] == 0 and V[v - 1] == 0:
		H[h - 1] = V[v - 1] = 1
		days.append(i)
print(*sorted(days), sep=' ')


n = list(map(int, input().split()))[0]
arr = list()
for i in range(n ** 2):
	arr.append(list(map(int, input().split())))
(b1, b2) = ([False] * n, [False] * n)
ans = ''
for i in range(n ** 2):
	a = arr[i][0] - 1
	b = arr[i][1] - 1
	if b1[a] == False and b2[b] == False:
		b1[a] = True
		b2[b] = True
		ans += (i + 1).__str__() + ' '
print(ans)


import sys
n = int(input())
hn = [0] * (n + 1)
vn = [0] * (n + 1)
result = []
for i in range(1, n * n + 1):
	(h, v) = map(int, sys.stdin.readline().split())
	if hn[h] == 0 and vn[v] == 0:
		result.append(i)
		hn[h] = 1
		vn[v] = 1
print(' '.join((str(i) for i in result)))


n = int(input())
a = list((list((False for i in range(n))) for j in range(n)))
t = 0
s = ''
for k in range(n * n):
	t += 1
	(h, v) = map(int, input().split())
	if a[h - 1][v - 1] == False:
		s += str(t) + ' '
		for l in range(n):
			a[h - 1][l] = True
			a[l][v - 1] = True
print(s[:-1])


n = int(input())
h = [False] * n
v = [False] * n
result = []
for i in range(n * n):
	(v_road, h_road) = map(int, input().split())
	if not h[h_road - 1] and (not v[v_road - 1]):
		h[h_road - 1] = v[v_road - 1] = True
		result += [i + 1]
print(' '.join(map(str, result)))


n = int(input())
vert = []
horiz = []
days = []
for i in range(n ** 2):
	(v, h) = map(int, input().split())
	if not v in vert and (not h in horiz):
		vert.append(v)
		horiz.append(h)
		days.append(i + 1)
print(' '.join(map(str, days)))


a = int(input())
x = []
y = []
res = []
for i in range(a ** 2):
	a = [i for i in input().split()]
	if a[0] not in x and a[1] not in y:
		res.append(int(i) + 1)
		x.append(a[0])
		y.append(a[1])
print(*res)


n = int(input())
h_list = [0] * (n + 1)
v_list = [0] * (n + 1)
ans = []
for x in range(1, n ** 2 + 1):
	(h, v) = map(int, input().split())
	if h_list[h] + v_list[v] == 0:
		h_list[h] = 1
		v_list[v] = 1
		ans.append(str(x))
print(' '.join(ans))


n = int(input()) ** 2
h = [1] * n
v = [1] * n
x = []
for i in range(n):
	(m, n) = map(int, input().split())
	if h[m - 1] and v[n - 1]:
		x.append(i + 1)
		h[m - 1] = 0
		v[n - 1] = 0
print(*x)


from math import sqrt, pow, log, log2, log10, exp
from copy import deepcopy

def read_ints():
	return list(map(int, input().split()))

def read_int():
	return read_ints()[0]

def read_floats():
	return list(map(float, input().split()))

def read_float():
	return read_floats()[0]

def one_dim_array(value, n):
	return [deepcopy(value) for x in range(n)]

def two_dim_array(value, n, m):
	return [[deepcopy(value) for x in range(m)] for x in range(n)]

def is_prime(n):
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	for i in range(3, sqrt(n) + 1):
		if n % i == 0:
			return False
	return True

def max_len_sublist(l, f):
	(start, max_length, length) = (0, 0, 0)
	for i in range(1, len(l)):
		if f(l[i], l[i - 1]):
			length += 1
		else:
			if max_length < length:
				start = i - length
				max_length = length
			length = 0
	return (start, max_length)

def tf_to_yn(b):
	return 'YES' if b else 'NO'
n = read_int()
d = set()
r = []
for i in range(1, n * n + 1):
	(a, b) = read_ints()
	if a not in d and b + n not in d:
		d.add(a)
		d.add(b + n)
		r.append(str(i))
print(' '.join(r))


TN = 1

def solution():
	n = int(input())
	ans = []
	xs = []
	ys = []
	for i in range(n ** 2):
		(x, y) = map(int, input().split())
		if x not in xs and y not in ys:
			ans.append(i + 1)
			xs.append(x)
			ys.append(y)
	print(*ans)
while TN != 0:
	solution()
	TN -= 1


n = int(input())
h_road = set()
v_road = set()
res = ''
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	if h not in h_road and v not in v_road:
		h_road.add(h)
		v_road.add(v)
		res += str(i + 1) + ' '
print(res)


n = int(input())
h = set()
v = set()
r = []
for i in range(n ** 2):
	(a, b) = (int(j) for j in input().split())
	if a not in h and b not in v:
		r.append(i + 1)
		h.add(a)
		v.add(b)
print(' '.join((str(i) for i in r)))


n = int(input())
x = [0 for i in range(n + 1)]
y = [0 for i in range(n + 1)]
res = []
for i in range(n ** 2):
	roads = [int(j) for j in input().split()]
	if x[roads[0]] == 0 and y[roads[1]] == 0:
		res.append(i + 1)
		x[roads[0]] = y[roads[1]] = 1
print(' '.join(map(str, sorted(res))))


n = int(input())
A = [list(map(int, input().split())) for i in range(n * n)]
day = []
dorgor = [i for i in range(1, n + 1)]
dorvert = [i for i in range(1, n + 1)]
for i in range(0, n * n):
	if len(dorgor) > 0 and len(dorvert) > 0:
		for j in range(1):
			if A[i][j] in dorgor and A[i][j + 1] in dorvert:
				day.append(i)
				dorgor.remove(A[i][j])
				dorvert.remove(A[i][j + 1])
for dni in day:
	print(dni + 1, end=' ')


n = int(input())
vert = [False for i in range(n)]
gor = [False for i in range(n)]
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	h -= 1
	v -= 1
	if not gor[h] and (not vert[v]):
		gor[h] = True
		vert[v] = True
		print(i + 1, end=' ')


(n, ans) = (int(input()), 0)
road_x = [0] * (n + 1)
road_y = [0] * (n + 1)
for i in range(n * n):
	(a, b) = map(int, input().split())
	if road_x[a] == road_y[b] == 0:
		print(i + 1, end=' ')
		road_x[a] = road_y[b] = 1


n = int(input())
used = [0] * (n + 1)
used1 = [0] * (n + 1)
for i in range(n * n):
	(a, b) = map(int, input().split())
	if used[a] + used1[b] == 0:
		(used[a], used1[b]) = (1, 1)
		print(i + 1, end=' ')


n = int(input())
(h, v) = ([False] * (n + 1), [False] * (n + 1))
for i in range(n * n):
	(x, y) = map(int, input().split())
	if not h[x] and (not v[y]):
		print(i + 1, end=' ')
		(h[x], v[y]) = (True, True)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
col = set()
row = set()
ans = []
for i in range(1, N ** 2 + 1):
	(r, c) = map(int, input().split())
	if r not in row and c not in col:
		ans.append(i)
		row.add(r)
		col.add(c)
print(' '.join(map(str, ans)))


n = int(input())
h = []
v = []
ans = ''
for i in range(0, n * n):
	given = list(map(int, input().split()))
	h1 = given[0]
	v1 = given[1]
	if h1 in h or v1 in v:
		x = 1
	else:
		h.append(h1)
		v.append(v1)
		ans += str(i + 1) + ' '
print(ans[:-1])


words = ''
n = int(input())
r = [0 for x in range(n)]
c = [0 for x in range(n)]
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	if not r[a - 1] and (not c[b - 1]):
		r[a - 1] = 1
		c[b - 1] = 1
		words += str(i + 1) + ' '
print(words)