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
Tags: Implementation

Starter code:

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=' ')


n = int(input())
X = [0 for i in range(n)]
Y = [0 for i in range(n)]
for i in range(n ** 2):
	(x, y) = map(int, input().split())
	if X[x - 1] + Y[y - 1] == 0:
		X[x - 1] = 1
		Y[y - 1] = 1
		print(i + 1)


(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())
h = []
v = []
l = []
for i in range(n * n):
	(x, y) = map(int, input().split())
	if x not in h and y not in v:
		l.append(i + 1)
		h.append(x)
		v.append(y)
print(*l)


n = int(input())
asphalted = []
ans = []
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	if 'R' + str(a) not in asphalted and 'V' + str(b) not in asphalted:
		asphalted.append('R' + str(a))
		asphalted.append('V' + str(b))
		ans.append(i + 1)
for i in ans:
	print(i, 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, dv, dh) = ([[0, 0]] + [[int(j) for j in input().split()] for i in range(0, n ** 2)], [False] * (n + 1), [False] * (n + 1))
for i in range(1, n ** 2 + 1):
	if dv[a[i][0]] == dh[a[i][1]] == False:
		dv[a[i][0]] = dh[a[i][1]] = True
		print(f'{i} ', end='')


nb_roads = int(input())
H = [0] * nb_roads
V = [0] * nb_roads
ans = []
for i in range(nb_roads * nb_roads):
	(h, v) = [int(x) for x in input().split()]
	if h in H or v in V:
		continue
	else:
		H.append(h)
		V.append(v)
		ans.append(i + 1)
print(*ans)


n = int(input())
n2 = n ** 2
vd = [0] * n
hd = [0] * n
for i in range(n2):
	(h, v) = map(int, input().split())
	h -= 1
	v -= 1
	if vd[v] == 0 and hd[h] == 0:
		(vd[v], hd[h]) = (1, 1)
		print(i + 1, end=' ')
print()


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())
dh = dict()
dv = dict()
ans = []
for i in range(n):
	dh[str(i + 1)] = 0
	dv[str(i + 1)] = 0
for i in range(n * n):
	(a, b) = [int(x) for x in input().split()]
	if dh[str(a)] == 0 and dv[str(b)] == 0:
		ans.append(i + 1)
		dh[str(a)] = 1
		dv[str(b)] = 1
print(*ans)


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))


l1 = []
l2 = []
a = int(input()) ** 2
for i in range(1, a + 1):
	(a, b) = input().split()
	if a not in l1 and b not in l2:
		print(i)
		l1.append(a)
		l2.append(b)


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)


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


n = int(input())
hr = []
vr = []
s = ''
for i in range(n ** 2):
	(h, v) = map(int, input().split())
	if h not in hr and v not in vr:
		hr.append(h)
		vr.append(v)
		s += str(i + 1) + ' '
print(s[:len(s) - 1])


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())
v = [0] * (n + 1)
h = [0] * (n + 1)
ans = []
for i in range(n * n):
	(th, tv) = [int(x) for x in input().split()]
	if not (v[tv] or h[th]):
		v[tv] = 1
		h[th] = 1
		ans.append(i + 1)
print(' '.join(map(str, ans)))


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)


from sys import stdin
n = int(stdin.readline())
v = [0] * (n + 1)
h = [0] * (n + 1)
for i in range(n * n):
	(a, b) = map(int, stdin.readline().split())
	if v[a] == 0 and h[b] == 0:
		print(i + 1)
		v[a] = h[b] = 1


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())
roadg = []
roadv = []
days = []
li = [[0, 0] for i in range(n * n)]
for i in range(n * n):
	(li[i][0], li[i][1]) = input().split()
for i in range(n * n):
	if li[i][0] not in roadg and li[i][1] not in roadv:
		roadg.append(li[i][0])
		roadv.append(li[i][1])
		days.append(i + 1)
print(' '.join(map(str, days)))


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())
a = []
for i in range(n * n):
	a.append([])
	a[i] = [int(x) for x in input().split()]
ansarr = []
r = [False for i in range(n)]
c = [False for i in range(n)]
for i in range(n * n):
	if r[a[i][0] - 1] == False and c[a[i][1] - 1] == False:
		r[a[i][0] - 1] = True
		c[a[i][1] - 1] = True
		ansarr.append(i + 1)
for i in range(len(ansarr)):
	print(ansarr[i], end=' ')
print('')


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))


seen_h = set()
seen_v = set()
n = int(input())
for i in range(n * n):
	(h, v) = [int(x) for x in input().split()]
	if h not in seen_h and v not in seen_v:
		print(str(i + 1))
		seen_h.add(h)
		seen_v.add(v)


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)


def solve():
	n = int(input())
	hs = [False] * 51
	vs = [False] * 51
	for i in range(n * n):
		(x, y) = map(int, input().split())
		if not hs[x] and (not vs[y]):
			print(i + 1)
			hs[x] = True
			vs[y] = True
solve()


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())
sc = []
for i in range(n ** 2):
	sc.append(list(map(int, input().split(' '))))
x = []
y = []
for i in range(n):
	x.append(i + 1)
	y.append(i + 1)
for j in range(len(sc)):
	if sc[j][0] in x:
		if sc[j][1] in y:
			x.remove(sc[j][0])
			y.remove(sc[j][1])
			print(j + 1)


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())
hor = set()
ver = set()
res = []
for i in range(n * n):
	(h, v) = map(int, input().split())
	if h not in hor and v not in ver:
		res.append(str(i + 1))
		hor.add(h)
		ver.add(v)
print(' '.join(res))


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=' ')


def mp():
	return map(int, input().split())

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

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def printlist(l):
	print(' '.join([str(x) for x in l]))

def listring(l):
	return ''.join([str(x) for x in l])
n = it()
already1 = []
already2 = []
already = []
for i in range(n * n):
	(m, p) = mp()
	if not m in already1 and (not p in already2):
		already1.append(m)
		already2.append(p)
		print(i + 1)


n = int(input().strip())
(x, y) = (set(), set())
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	if a not in x and b not in y:
		x.add(a)
		y.add(b)
		print(i + 1)


from collections import defaultdict
(xd, yd) = (defaultdict(bool), defaultdict(bool))
for i in range(int(input()) ** 2):
	(x, y) = map(int, input().split())
	if not (xd[x] or yd[y]):
		xd[x] = yd[y] = True
		print(i + 1)


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())
x = [1]
y = [1]
for i in range(1, n + 1):
	x.append(0)
	y.append(0)
for i in range(1, n ** 2 + 1):
	str = input()
	(a, b) = str.split()
	a = int(a)
	b = int(b)
	if x[a] == 0 and y[b] == 0:
		x[a] = 1
		y[b] = 1
		print(i)


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())
r = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(n * n):
	(a, b) = map(int, input().split())
	if r[a] == 0 and c[b] == 0:
		print(i + 1)
		r[a] = c[b] = 1


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)))


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


__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=' ')


z = set()
z1 = set()
for i in range(int(input()) ** 2):
	(a, b) = map(int, input().split())
	if a not in z and b not in z1:
		print(i + 1)
		z.add(a)
		z1.add(b)


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())
A = []
for i in range(0, n ** 2):
	(a, b) = input().split()
	A.append([int(a), int(b)])
B = []
C = []
for l in range(0, n):
	B.append(0)
	C.append(0)
D = []
for k in range(0, n ** 2):
	if B[A[k][0] - 1] == 0 and C[A[k][1] - 1] == 0:
		D.append(k)
		B[A[k][0] - 1] = 1
		C[A[k][1] - 1] = 1
s = ''
for j in range(0, n):
	s = s + str(D[j] + 1) + ' '
print(s)


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())
mass = []
mass.append([])
mass.append([])
ans = '1 '
(a1, a2) = map(int, input().split())
mass[0].append(a1)
mass[1].append(a2)
for i in range(2, n * n + 1):
	(a1, a2) = map(int, input().split())
	k = 0
	for j in range(len(mass[0])):
		if mass[0][j] == a1 or mass[1][j] == a2:
			k = 1
	if k == 0:
		mass[0].append(a1)
		mass[1].append(a2)
		ans = ans + str(i) + ' '
print(ans)


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())
a = list(range(1, n + 1))
b = list(range(1, n + 1))
for i in range(n * n):
	(n, m) = map(int, input().split())
	if n in a and m in b:
		print(i + 1, end=' ')
		a.pop(a.index(n))
		b.pop(b.index(m))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = [LI() for _ in range(n * n)]
	r = set()
	c = set()
	rr = []
	for i in range(n * n):
		(t, u) = a[i]
		if t not in r and u not in c:
			rr.append(i + 1)
			r.add(t)
			c.add(u)
	return ' '.join(map(str, rr))
print(main())


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)


n = int(input())
AsphaltedV = []
AsphaltedH = []
for i in range(n ** 2):
	(H, V) = map(int, input().split())
	if H not in AsphaltedH and V not in AsphaltedV:
		AsphaltedH.append(H)
		AsphaltedV.append(V)
		print(i + 1)


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


n = int(input())
crossroads = [0] * n ** 2
for i in range(n ** 2):
	crossroads[i] = [item for item in input().split()]
done = [[0] * n for i in range(2)]
days = []
for i in range(n ** 2):
	if crossroads[i][0] not in done[0] and crossroads[i][1] not in done[1]:
		done[0].append(crossroads[i][0])
		done[1].append(crossroads[i][1])
		days.append(i + 1)
print(' '.join(map(str, days)))


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())
hs = [0] * n
vs = [0] * n
days = []
for i in range(n * n):
	(h, v) = [int(i) for i in input().split()]
	if not hs[h - 1] and (not vs[v - 1]):
		hs[h - 1] = 1
		vs[v - 1] = 1
		days.append(i + 1)
for i in days:
	print(i, end=' ')
print()


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())
t = []
d = []
s = []
for x in range(n * n):
	(k, l) = list(map(int, input().split()))
	if k not in t and l not in d:
		s.append(x + 1)
		t.append(k)
		d.append(l)
	else:
		pass
print(*s)


from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
arr = lambda : list(map(int, input().strip().split()))

def main():
	t = inp()
	rowset = {0}
	colset = {0}
	ans = []
	for i in range(t * t):
		(n, m) = mul()
		if n not in rowset:
			if m not in colset:
				rowset.add(n)
				colset.add(m)
				ans.append(i + 1)
	print(*ans)
main()


n = int(input())
h = [False] * n
v = [False] * n
day_numbers = []
for day in range(1, n ** 2 + 1):
	(hi, vi) = [int(x) - 1 for x in input().split()]
	if not h[hi] and (not v[vi]):
		h[hi] = v[vi] = True
		day_numbers.append(day)
print(*day_numbers)


n = int(input())
(x, y) = ([], [])
for i in range(n * n):
	(x1, y1) = input().split()
	(x2, y2) = (len(x), len(y))
	flag = 0
	for j in range(x2):
		if x1 == x[j]:
			flag = 1
	for j in range(y2):
		if y1 == y[j]:
			flag = 1
	if flag == 0:
		x.append(x1)
		y.append(y1)
		print(i + 1)


n = int(input())
data = [list(map(int, input().split())) for i in range(n ** 2)]
vertical = [0 for i in range(n)]
horizontal = [0 for i in range(n)]
answer = []
for i in range(n ** 2):
	if vertical[data[i][0] - 1] == 0 and horizontal[data[i][1] - 1] == 0:
		(vertical[data[i][0] - 1], horizontal[data[i][1] - 1]) = (1, 1)
		answer.append(i + 1)
print(' '.join(map(str, answer)))


while 1:
	try:
		n = int(input())
		(a, b) = ([0] * (n * n), [0] * (n * n))
		for i in range(n * n):
			(a[i], b[i]) = map(int, input().split())
	except:
		break
	(s, t) = (set(), set())
	res = []
	for i in range(n * n):
		if not a[i] in s and (not b[i] in t):
			res.append(i + 1)
			s.add(a[i])
			t.add(b[i])
	print(' '.join(map(str, res)))


n = int(input())
hor_roads_repaired = []
ver_roads_repaired = []
for i in range(n ** 2):
	(hor_road, ver_road) = map(int, input().split())
	if hor_road not in hor_roads_repaired and ver_road not in ver_roads_repaired:
		hor_roads_repaired += [hor_road]
		ver_roads_repaired += [ver_road]
		print(i + 1, end=' ')
print()


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


import sys
Input = lambda : map(int, sys.stdin.readline().split())
n = int(sys.stdin.readline())
res = list()
Tmph = dict()
Tmpv = dict()
for i in range(n * n):
	(h, v) = Input()
	if Tmph.get(h, -1) == -1 and Tmpv.get(v, -1) == -1:
		res.append(i + 1)
		Tmph[h] = 1
		Tmpv[v] = 1
print(*res)


__author__ = 'artyom'

def main():
	n = read()
	hb = [False] * n
	vb = [False] * n
	r = []
	for i in range(n * n):
		(h, v) = read(3)
		if not hb[h - 1] and (not vb[v - 1]):
			r.append(i + 1)
			hb[h - 1] = vb[v - 1] = True
	return r

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


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


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


n = int(input())
f = [0] * (n * n)
s = [0] * (n * n)
for i in range(n * n):
	(f[i], s[i]) = map(int, input().split())
vert = [0] * n
hor = [0] * n
res = []
for i in range(n * n):
	if hor[f[i] - 1] == 0 and vert[s[i] - 1] == 0:
		hor[f[i] - 1] = 1
		vert[s[i] - 1] = 1
		res.append(i + 1)
for elem in res:
	print(elem, end=' ')


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)


n = int(input())
v = [0] * (n + 1)
h = [0] * (n + 1)
i = 1
while i <= n * n:
	(a, b) = map(int, input().split())
	if v[a] == 0 and h[b] == 0:
		v[a] = h[b] = 1
		print(i, sep=' ', end=' ')
	i += 1


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


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


n = int(input())
vertical = n * [0]
horizontal = n * [0]
work = []
for i in range(n ** 2):
	(v, h) = [int(j) for j in input().split()]
	if vertical[v - 1] == 1 or horizontal[h - 1] == 1:
		continue
	else:
		vertical[v - 1] = 1
		horizontal[h - 1] = 1
		work.append(str(i + 1))
print(' '.join(work))


def AspRoa():
	n = int(input())
	n = n * n
	l = [''] * 2505
	k = [''] * 2505
	m = []
	for i in range(n):
		j = input().split()
		if not l[int(j[0])] and (not k[int(j[1])]):
			l[int(j[0])] = '1'
			k[int(j[1])] = '1'
			m.append(str(i + 1))
	print(' '.join(m))
AspRoa()


X = int(input())
V = list()
H = list()
for i in range(X ** 2):
	Roads = list(map(int, input().split()))
	if Roads[0] not in H and Roads[1] not in V:
		print(i + 1, end=' ')
		H.append(Roads[0])
		V.append(Roads[1])


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
(n,) = map(int, sys.stdin.readline().split())
sr = set()
sc = set()
for i in range(1, n * n + 1):
	(r, c) = map(int, sys.stdin.readline().split())
	if r in sr or c in sc:
		continue
	else:
		print(i, end=' ')
		sr.add(r)
		sc.add(c)


blbost = int(input())
radky = []
sloupce = []
for k in range(blbost ** 2):
	line = list(map(int, input().split()))
	m = line[0] in radky
	l = line[1] in sloupce
	if m or l:
		continue
	else:
		print(k + 1, end=' ')
		radky.append(line[0])
		sloupce.append(line[1])


n = int(input())
schedule = []
for i in range(0, n * n):
	(h, v) = input().split()
	schedule.append([i, int(h) - 1, int(v) - 1])
vert = []
hor = []
for i in range(0, n):
	vert.append(False)
	hor.append(False)
for task in schedule:
	(i, h, v) = task
	if hor[h] or vert[v]:
		continue
	else:
		hor[h] = True
		vert[v] = True
		print(i + 1, ' ')


N = int(input())
Roadx = [0] * 120
Roady = [0] * 100
for i in range(1, N * N + 1):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if Roadx[x] == 0 and Roady[y] == 0:
		print(i, end=' ')
		Roadx[x] = Roady[y] = 1


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


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


n = int(input())
hor = [False] * n
ver = [False] * n
for i in range(n * n):
	k = list(map(int, input().split()))
	if not (hor[k[0] - 1] == True or ver[k[1] - 1] == True):
		ver[k[1] - 1] = True
		hor[k[0] - 1] = True
		print(i + 1, end=' ')


n = int(input())
paved_rows = set()
paved_columns = set()
result = []
for i in range(n * n):
	(r, c) = map(int, input().split())
	if r in paved_rows or c in paved_columns:
		continue
	result.append(i + 1)
	paved_rows.add(r)
	paved_columns.add(c)
print(' '.join(map(str, result)))


n = int(input())
v = [0 for i in range(n)]
h = [0 for i in range(n)]
ans = []
for i in range(n ** 2):
	(ch, cv) = list(map(int, input().split()))
	if v[cv - 1] == 0 and h[ch - 1] == 0:
		v[cv - 1] = 1
		h[ch - 1] = 1
		ans.append(i + 1)
print(' '.join(list(map(str, ans))))


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


n = int(input())
L = [[-1] * n] * n
L1 = []
for k in range(n ** 2):
	(a, b) = map(int, input().split())
	if L[a - 1][b - 1] == -1:
		L[a - 1] = [1] * n
		L1 += [str(k + 1)]
		for j in range(n):
			L[j][b - 1] = 1
print(' '.join(L1))


n = int(input())
hl = []
vl = []
z = []
for i in range(n ** 2):
	(a, b) = list(map(int, input().split()))
	if a in hl or b in vl:
		pass
	else:
		z.append(str(i + 1))
		hl.append(a)
		vl.append(b)
print(' '.join(z))


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


import sys
import math
import bisect
import itertools
import random
import re

def main():
	n = int(input())
	row = [0] * n
	col = [0] * n
	B = []
	for i in range(n * n):
		(x, y) = map(int, input().split())
		x -= 1
		y -= 1
		if row[x] == 0 and col[y] == 0:
			B.append(i)
			row[x] = 1
			col[y] = 1
	print(' '.join(list((str(a + 1) for a in B))))
main()


n = int(input())
(a, b, c) = ([False] * n, [False] * n, [])
for k in range(n ** 2):
	(i, j) = map(int, input().split())
	if a[i - 1] == False and b[j - 1] == False:
		c.append(k + 1)
		(a[i - 1], b[j - 1]) = (True, True)
print(*c)


n = int(input())
matrix = []
for i in range(n * n):
	matrix.append(tuple(map(int, input().split())))
row = set()
col = set()
lst = []
for i in range(n * n):
	if matrix[i][0] not in row and matrix[i][1] not in col:
		row.add(matrix[i][0])
		col.add(matrix[i][1])
		lst.append(i + 1)
print(*lst)


n = int(input())
line_h = [1] * n
line_v = [1] * n
value = list()
for i in range(n * n):
	(h, v) = str(input()).split()
	h = int(h) - 1
	v = int(v) - 1
	if line_h[h] and line_v[v]:
		line_h[h] = 0
		line_v[v] = 0
		value.append(str(i + 1))
print(' '.join(value))


n = int(input())
lst_h = [i for i in range(1, n + 1)]
lst_v = [i for i in range(1, n + 1)]
result = []
count = 0
if n == 1:
	x = input()
	print(1)
else:
	for i in range(n ** 2):
		(h, v) = map(int, input().split())
		if h in lst_h and v in lst_v:
			lst_h.remove(h)
			lst_v.remove(v)
			count += 1
			result.append(str(count))
			if lst_h == [] and lst_v == []:
				break
		else:
			count += 1
	if count != n ** 2:
		for i in range(n ** 2 - count):
			x = input()
	print(' '.join(result))


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


n = int(input())
h = []
v = []
d = []
c = 0
for i in range(1, n + 1):
	h.append(i)
	v.append(i)
r = len(h)
for i in range(1, n * n + 1):
	(a, b) = map(int, input().split())
	c += 1
	if a in h:
		if b in v:
			v.remove(b)
			h.remove(a)
			d.append(i)
			if r == 0:
				break
print(*d)


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


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


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=' ')


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


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


n = int(input())
x = []
y = []
k = 0
ans = ''
for i in range(n * n):
	s = [int(j) for j in input().split(' ')]
	h = s[0]
	v = s[1]
	if h not in y and v not in x:
		y.append(h)
		x.append(v)
		ans = ans + str(i + 1) + ' '
print(ans)


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())
h = [0] * (n + 1)
v = [0] * (n + 1)
for i in range(n * n):
	(hi, vi) = map(int, input().split())
	if h[hi] == 0 and v[vi] == 0:
		print(i + 1)
		h[hi] = 1
		v[vi] = 1


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)


n = int(input())
c = set()
r = set()
for i in range(n ** 2):
	(x, y) = map(int, input().split())
	if x not in r and y not in c:
		print(i + 1)
		r.add(x)
		c.add(y)


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())
xs = set(range(1, n + 1))
ys = set(range(1, n + 1))
for _ in range(1, n ** 2 + 1):
	(x, y) = map(int, input().split())
	if x in xs and y in ys:
		print(_)
		xs.discard(x)
		ys.discard(y)


n = int(input())
s_x = set()
s_y = set()
for i in range(n ** 2):
	(x, y) = map(int, input().strip().split())
	if not x in s_x and (not y in s_y):
		print(i + 1)
		s_x.add(x)
		s_y.add(y)


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


from sys import stdin, stdout
input = stdin.readline
n = int(input())
v = [False] * (n + 1)
h = [False] * (n + 1)
ans = ' '
for i in range(n * n):
	(x, y) = map(int, input().split())
	if not (v[x] or h[y]):
		ans += str(i + 1) + ' '
		v[x] = True
		h[y] = True
stdout.write(ans[1:-1])


from sys import stdin
live = True
if not live:
	stdin = open('data.in', 'r')
n = int(stdin.readline().strip())
vert = [False] * (n + 1)
hori = [False] * (n + 1)
ans = []
for it in range(n * n):
	(x, y) = list(map(int, stdin.readline().strip().split()))
	if not hori[x] and (not vert[y]):
		hori[x] = vert[y] = True
		ans += [it + 1]
print(' '.join(map(str, ans)))
if not live:
	stdin.close()


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


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


n = int(input())
s = []
(h, v) = (set(), set())
for _ in range(n ** 2):
	i = list(map(int, input().split()))
	s.append(i)
	h.add(i[0])
	v.add(i[1])
for x in range(n ** 2):
	if s[x][0] in h and s[x][1] in v:
		h.remove(s[x][0])
		v.remove(s[x][1])
		print(x + 1, end=' ')


def getDays(n, sched):
	rbit = [0 for i in range(n + 1)]
	cbit = [0 for i in range(n + 1)]
	days = []
	for (day, inter) in enumerate(sched):
		if rbit[inter[0]] == 0 and cbit[inter[1]] == 0:
			rbit[inter[0]] = 1
			cbit[inter[1]] = 1
			days.append(day + 1)
	return days
n = int(input())
sched = []
for i in range(n ** 2):
	sched.append(list(map(int, input().split())))
days = getDays(n, sched)
for d in days:
	print(d, end=' ')


n = int(input())
kruispunten = []
horizontaal = set()
verticaal = set()
dagen = []
for i in range(0, n ** 2):
	kruispunten.append(list(map(int, input().split(' '))))
for j in range(0, n ** 2):
	if kruispunten[j][0] in horizontaal or kruispunten[j][1] in verticaal:
		pass
	else:
		horizontaal.add(kruispunten[j][0])
		verticaal.add(kruispunten[j][1])
		dagen.append(j + 1)
for x in dagen:
	print(x, end=' ')


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


n = int(input())
tmp_h = [False] * (n + 1)
tmp_v = [False] * (n + 1)
answer = []
for i in range(1, n ** 2 + 1):
	(h, v) = map(lambda x: int(x) - 1, input().split())
	if not tmp_h[h] and (not tmp_v[v]):
		tmp_h[h] = True
		tmp_v[v] = True
		answer.append(i)
print(' '.join(map(str, answer)))


n = int(input())
gor = [False] * (n + 2)
vert = [False] * (n + 2)
ans = 0
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	if gor[a] == False and vert[b] == False:
		gor[a] = True
		vert[b] = True
		print(i + 1, end=' ')


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


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)


n = int(input())
l = []
s = set()
ss = set()
for i in range(n * n):
	(x, y) = map(int, input().split())
	if x in s or y in ss:
		continue
	else:
		s.add(x)
		ss.add(y)
		l.append(i + 1)
print(*l)


class CodeforcesTask583ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.schedule = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n ** 2):
			self.schedule.append([int(y) for y in input().split(' ')])

	def process_task(self):
		vertical = [False for x in range(self.n)]
		horizontal = [False for x in range(self.n)]
		workdays = []
		for x in range(self.n ** 2):
			if not vertical[self.schedule[x][0] - 1] and (not horizontal[self.schedule[x][1] - 1]):
				workdays.append(x + 1)
				vertical[self.schedule[x][0] - 1] = True
				horizontal[self.schedule[x][1] - 1] = True
		self.result = ' '.join([str(x) for x in workdays])

	def get_result(self):
		return self.result
Solution = CodeforcesTask583ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


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


t = int(input()) ** 2
table1 = []
table2 = []
ans = []
for i in range(t):
	l1 = [int(x) for x in input().split()]
	if l1[0] in table1 or l1[1] in table2:
		pass
	else:
		table1.append(l1[0])
		table2.append(l1[1])
		ans.append(i + 1)
print(*ans)


n = int(input())
Hlist = [0 for i in range(1, 100)]
Vlist = [0 for i in range(1, 100)]
for i in range(n * n):
	(h, v) = map(int, input().split())
	if Hlist[h] == 0 and Vlist[v] == 0:
		print(i + 1)
		if h < 100 and h > 0:
			Hlist[h] = 1
		if v < 100 and v > 0:
			Vlist[v] = 1


n = int(input())
p1 = [0] * n
p2 = [0] * n
for i in range(n ** 2):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	if p1[a] == 0 and p2[b] == 0:
		p1[a] = 1
		p2[b] = 1
		print(i + 1, end=' ')


n = int(input())
(h, v) = ([True for i in range(n)], [True for i in range(n)])
odpovede = []
for den in range(n ** 2):
	(h_i, v_i) = [int(i) - 1 for i in input().split()]
	if h[h_i] and v[v_i]:
		h[h_i] = False
		v[v_i] = False
		odpovede.append(den + 1)
print(' '.join(map(str, odpovede)))


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)