Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as p_{i}. For all pairs of distinct integers i, j between 1 and n, he wrote the number a_{i}, j = min(p_{i}, p_{j}). He writes a_{i}, i = 0 for all integer i from 1 to n.

Bob gave you all the values of a_{i}, j that he wrote down. Your job is to reconstruct any permutation that could have generated these values. The input will be formed so that it is guaranteed that there is at least one solution that is consistent with the information given.


-----Input-----

The first line of the input will contain a single integer n (2 ≤ n ≤ 50).

The next n lines will contain the values of a_{i}, j. The j-th number on the i-th line will represent a_{i}, j. The i-th number on the i-th line will be 0. It's guaranteed that a_{i}, j = a_{j}, i and there is at least one solution consistent with the information given.


-----Output-----

Print n space separated integers, which represents a permutation that could have generated these values. If there are multiple possible solutions, print any of them.


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

Output
2 1

Input
5
0 2 2 1 2
2 0 4 1 3
2 4 0 1 3
1 1 1 0 1
2 3 3 1 0

Output
2 5 4 1 3



-----Note-----

In the first case, the answer can be {1, 2} or {2, 1}.

In the second case, another possible answer is {2, 4, 5, 1, 3}.

Source: codeforces | Difficulty: EASY
Tags: Constructive algorithms


Solutions:
def main():
	n = int(input())
	aa = list((tuple(map(int, input().split())) for _ in range(n)))
	cnt = []
	for row in aa:
		l = [0] * n
		for x in row:
			l[x] += 1
		cnt.append(l)
	res = [0] * n
	for x in range(1, n):
		i = max(range(n), key=lambda i: cnt[i][x])
		res[i] = x
	for (i, x) in enumerate(res):
		if not x:
			res[i] = n - 1
		elif x == n - 1:
			res[i] = n
	print(*res)
main()


from itertools import chain
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	a[i][i] = i
ans = []
while n > 0:
	done = False
	for i in chain(range(1, n - 1), [0, n - 1]):
		if done:
			break
		b = True
		for dx in (-1, 0, 1):
			for dy in (-1, 0, 1):
				if dx != 0 and dy != 0:
					continue
				if dx == 0 and dy == 0:
					continue
				(nx, ny) = (i + dx, i + dy)
				if nx < 0 or nx >= n:
					continue
				if ny < 0 or ny >= n:
					continue
				b = b and a[nx][ny] == 1
		if b:
			ans.append(a[i][i])
			if i < n - 1:
				a = a[:i] + a[i + 1:]
			else:
				a = a[:i]
			for j in range(len(a)):
				if i < n - 1:
					a[j] = a[j][:i] + a[j][i + 1:]
				else:
					a[j] = a[j][:i]
			for x in range(len(a)):
				for y in range(len(a)):
					if x == y:
						continue
					a[x][y] -= 1
			n -= 1
			done = True
	if not done:
		return
ret = [0] * len(ans)
for i in range(len(ans)):
	ret[ans[i]] = i + 1
for i in ret:
	print(i, end=' ')


n = int(input())
a = []
for i in range(n):
	a.append([int(i) for i in input().split()])
b = [0 for i in range(n)]
c = {}
for i in range(n):
	for j in range(n):
		c[j] = 0
	for j in range(n):
		c[a[i][j]] += 1
	for j in range(n):
		if j in c and c[j] > 1:
			b[i] = j
i1 = -1
m = 0
for i in range(n):
	if b[i] == 0:
		l = max(a[i])
		if l > m:
			m = l
			i1 = i
b[i1] = n - 1
for i in range(n):
	if b[i] == 0 and i != i1:
		b[i] = n
for e in b:
	print(e, end=' ')
print()


n = int(input())
A = []
for i in range(n):
	L = list(map(int, input().split(' ')))
	A.append(max(L))
A[A.index(n - 1)] = n
for i in A:
	print(i, end=' ')


import sys
f = sys.stdin
n = int(f.readline())
arr = [max(map(int, f.readline().split())) for i in range(n)]
arr[arr.index(n - 1)] = n
print(' '.join(map(str, arr)))


def s():
	n = int(input())
	a = []
	for _ in range(n):
		a.append(max(map(int, input().split(' '))))
	a[a.index(n - 1)] = n
	print(*a)
s()


n = int(input())
a = []
for i in range(n):
	a.append(input().split(' '))
	a[i] = map(int, a[i])
	a[i] = list(a[i])
f = [0] * n
for i in range(n):
	f[i] = len(set(a[i]))
	if f[i] == n:
		imax = i
		break
resp = [0] * n
resp[imax] = n
for i in range(n):
	if i != imax:
		resp[i] = a[imax][i]
for i in range(n):
	print(resp[i], end=' ')
print()


n = int(input())
nums = [0 for i in range(1, n + 1)]
i = 0
while i < n:
	permutation = list(map(int, input().split()))
	j = 0
	for p in permutation:
		nums[j] = max(nums[j], p)
		j += 1
	i += 1
maximumNums = max(nums)
for num in nums:
	if maximumNums == num:
		idx = nums.index(num)
		nums[idx] = n
		break
print(*nums)


n = int(input())
a = []
p = [0] * n
for i in range(n):
	a += [list(map(int, input().split()))]
	if max(a[i]) == n - 1:
		for j in range(n):
			if a[i][j] == 0:
				a[i][j] = n
		print(*a[i])
		break


num = int(input())
arra = []
for i in range(num):
	arr_gen = list(map(int, input().split()))
	if max(arr_gen) in arra:
		arra.append(max(arr_gen) + 1)
	else:
		arra.append(max(arr_gen))
for i in arra:
	print(i, end=' ')


__author__ = 'Admin'
n = int(input())
m = [list(map(int, input().split())) for j in range(n)]
ans = []
for i in range(n):
	if len(ans) > 0:
		if max(m[i]) == max(ans):
			ans.append(max(m[i]) + 1)
		else:
			ans.append(max(m[i]))
	else:
		ans.append(max(m[i]))
print(*ans)


n = int(input())
s = []
for _ in range(n):
	l = [int(b) for b in input().split()]
	s.append(max(l))
i = s.index(max(s))
s[i] = n
for c in s:
	print(f'{c}', end=' ')


v = [max(map(int, input().split())) for i in range(int(input()))]
v[v.index(max(v))] += 1
print(' '.join(map(str, v)))


n = int(input())
saida = []
for _ in range(n):
	l = [int(x) for x in input().split()]
	saida.append(max(l))
i = saida.index(max(saida))
saida[i] = n
print(' '.join(map(str, saida)))


n = int(input())
permutation = []
for _ in range(n):
	S = set(input().split())
	permutation.append(len(S) - 1)
for i in range(n):
	if permutation[i] == n - 1:
		permutation[i] += 1
		break
print(*permutation)


n = int(input())
R = lambda : map(int, input().split())
v = []
for i in range(n):
	v.append((max(R()), i))
r = [0] * n
v = sorted(v)
for i in range(n):
	r[v[i][1]] = i + 1
print(*r)


n = int(input())
for i in range(n):
	k = list(map(int, input().split()))
	if len(set(k)) == n:
		k[k.index(0)] = n
		print(*k)
		break


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
res = list()
used = set()
for i in range(n):
	count = dict()
	for j in range(n):
		if i == j:
			continue
		if a[i][j] not in count:
			count[a[i][j]] = 0
		count[a[i][j]] += 1
	for c in count:
		if n - count[c] == c:
			if c in used:
				res.append(c + 1)
			else:
				res.append(c)
			used.add(c)
print(' '.join(map(str, res)))


n = int(input())
a = [max(map(int, input().split())) for i in range(n)]
a[a.index(n - 1)] = n
print(*a)


n = int(input())
a = [list(map(int, input().split(' '))) for i in range(n)]
ans = [0] * n
for i in range(1, n + 1):
	for j in range(n):
		if ans[j] == 0 and a[j].count(i) == n - i:
			ans[j] = str(i)
			break
print(' '.join(ans))


n = int(input())
t = []
for i in range(n):
	t.append(map(int, input().split()))
result = []
n_set = False
for row in t:
	m = max(row)
	if m == n - 1:
		if not n_set:
			result.append(n - 1)
			n_set = True
		else:
			result.append(n)
	else:
		result.append(m)
for i in result:
	print(i, end=' ')


n = int(input())
from collections import Counter
ans = [0] * n
for ind in range(n):
	a = [int(i) for i in input().split()]
	c = Counter(a)
	maxi = 0
	for i in c:
		if c[i] > maxi:
			maxi = c[i]
			curr = i
	if maxi > 1:
		ans[ind] = curr
z = n
for i in range(n):
	if ans[i] == 0:
		ans[i] = z
		z -= 1
print(*ans)


a = int(input())
m = []
for i in range(a):
	m.append([int(x) for x in input().split()])
minn = set()
minn.add(0)
ans = [0 for i in range(a)]
for k in range(1, a + 1):
	for i in range(a):
		cont = True
		for j in range(a):
			if m[i][j] > k or ans[i] != 0:
				cont = False
		if cont:
			ans[i] = k
			break
print(*ans)


n = int(input())
lines = []
for i in range(n):
	line = [int(x) for x in input().split(' ')]
	lines.append(line)
result = []
max_n = False
for line in lines:
	d = {x: 0 for x in range(0, n)}
	for l in line:
		d[l] += 1
	max_int = 0
	for key in d:
		if d[key] > max_int:
			max_int = d[key]
			max_key = key
	if max_int == 1 and max_n == False:
		result.append(n)
		max_n = True
	elif max_int == 1 and max_n == True:
		result.append(n - 1)
	else:
		result.append(max_key)
print(' '.join(map(str, result)))


n = int(input())
a = [list(map(int, input().split())) for x in range(n)]
result = [0] * n
for x in range(1, n):
	result[max(list(range(n)), key=lambda i: a[i].count(x))] = x
print(*[x if x else n for x in result])


import time
n = int(input())
a = []
for i in range(n):
	a.append(max([int(i) for i in input().split()]))
start = time.time()
for i in range(n):
	if a[i] == n - 1:
		a[i] += 1
		break
for i in a:
	print(i, end=' ')
print()
finish = time.time()


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	is_dif = True
	for j in range(n):
		c = a[i].count(a[i][j])
		if c > 1:
			is_dif = False
			break
	if is_dif:
		for k in range(n):
			if a[i][k] == 0:
				a[i][k] = n
			print(a[i][k], end=' ')
		break


n = int(input())
matrix = []
for r in range(0, n):
	matrix.append(list(map(int, list(input().split()))))
ans = []
for line in matrix:
	k = max(line)
	while k in ans:
		k += 1
	ans.append(k)
f = ''
for w in ans:
	f += str(w)
	f += ' '
print(f[:-1])


n = int(input())
z = set(range(1, n + 1))
for q in range(n):
	x = max((int(s) for s in input().split()))
	p = min((i for i in z if i >= x))
	z -= {p}
	print(p, end=' ')


3

def remove(A, i, n):
	for j in range(n):
		A[i][j] = 0
		A[j][i] = 0
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
ans = [0 for i in range(n)]
for i in range(n - 1):
	t = -1
	for j in range(n):
		f = True
		g = False
		for k in range(n):
			if not (A[j][k] in (0, i + 1) and A[k][j] in (0, i + 1)):
				f = False
			if A[j][k] != 0:
				g = True
		if f and g:
			t = j
	ans[t] = i + 1
	remove(A, t, n)
for i in range(n):
	if ans[i] == 0:
		ans[i] = n
print(' '.join(map(str, ans)))


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
op = [0 for i in range(n)]
for i in range(n):
	for j in range(i + 1, n):
		(op[i], op[j]) = (max(l[i][j], op[i]), max(l[i][j], op[j]))
ok = max(op)
s = ''
for i in op:
	if i == ok:
		s += str(ok + 1)
		ok = -1
	else:
		s += str(i)
	s += ' '
print(s)


n = int(input())
a = []
res = [-1] * n
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n - 1):
	for j in range(i + 1, n):
		res[i] = max(res[i], a[i][j])
		res[j] = max(res[j], a[i][j])
seen = [0] * (n + 1)
for i in res:
	seen[i] = 1
r = []
for i in range(1, n + 1):
	if seen[i] == 0:
		r.append(i)
ind = 0
seen = [0] * (n + 1)
for i in range(n):
	if seen[res[i]] == 0:
		seen[res[i]] = 1
	else:
		res[i] = r[ind]
		ind += 1
print(*res)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = [n - 1, n]
for i in range(n):
	l = il()
	if len(set(l)) == n:
		for i in range(n):
			if l[i] == 0:
				l[i] = n
		exit(print(*l))


n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
ans = []
for i in arr:
	anf = max(i)
	while anf in ans:
		anf += 1
	ans.append(anf)
print(*ans)


n = int(input())
d = [list(map(int, input().split())) for i in range(0, n)]
c = 0
for i in range(0, n):
	has = False
	for num in range(1, n + 1):
		if d[i].count(num) >= 2:
			has = True
			print(num, end=' ')
	if not has:
		print(n - c, end=' ')
		c += 1


n = int(input())
a = [0] * n
m = [0] * n
for i in range(n):
	a[i] = tuple(map(int, input().split()))
for i in range(n):
	m[i] = max(a[i])
res = [0] * n
for i in range(n):
	for j in range(n):
		if m[j] <= i + 1 and res[j] == 0:
			res[j] = i + 1
			break
for i in res:
	print(str(i), end=' ')


n = int(input())
a = [] * n
idx = -1
for i in range(n):
	a.append(list(map(int, input().split())))
	cnt = 0
	for j in range(n):
		cnt += a[i][j]
	if cnt == n - 1:
		idx = i
vis = [0] * n
vis[idx] = 1
for i in range(2, n + 1):
	for j in range(n):
		if vis[j]:
			continue
		t = set()
		for k in range(n):
			if vis[k] == 0 and a[j][k] > 0:
				t.add(a[j][k])
		if len(t) == 1:
			vis[j] = i
			break
for i in range(n):
	if vis[i] == 0:
		print(n, end=' ')
	else:
		print(vis[i], end=' ')


N = int(input())
min_arr = [0 for _ in range(N)]
for i in range(N):
	arr_i = [n - 1 for n in map(int, input().split())]
	for j in range(N):
		if i == j:
			continue
		min_arr[i] = max(arr_i[j], min_arr[i])
		min_arr[j] = max(arr_i[j], min_arr[j])
assign = [0 for _ in range(N)]
blah = [(min_arr[i], i) for i in range(N)]
blah.sort()
for i in range(N):
	assign[blah[i][1]] = i + 1
print(' '.join(map(str, assign)))


n = int(input())
x = list()
for i in range(n):
	y = input().split(' ')
	y = [int(k) for k in y]
	y = int(max(y))
	x.append(y)
s = set()
for i in range(n):
	s.add(i + 1)
for i in range(len(x)):
	if x[i] not in s:
		t = 1
		while x[i] + t not in s:
			t += 1
		x[i] += t
	s.remove(x[i])
print(str(x).replace('[', '').replace(']', '').replace(',', ''))


n = int(input())
T = []
for i in range(n):
	T.append(list(map(int, input().split())))
ans = [-1] * n
for i in range(n):
	if ans[i] != -1:
		continue
	for j in range(len(T[i])):
		for k in range(j + 1, len(T[i])):
			if T[i][j] == T[i][k]:
				ans[i] = T[i][j]
				break
		if ans[i] != -1:
			for k in range(n):
				if T[i][k] != ans[i] and ans[k] == -1:
					ans[k] = T[i][k]
			break
for i in range(n):
	if ans[i] == -1:
		for j in range(i + 1, n):
			if ans[j] == -1:
				ans[i] = T[i][j]
				for k in range(n):
					if T[i][k] != ans[i] and ans[k] == -1:
						ans[k] = T[i][k]
temp = (n + 1) * n // 2
for i in range(n):
	if ans[i] != -1:
		temp = temp - ans[i]
for i in range(n):
	if ans[i] == -1:
		ans[i] = temp
print(' '.join((str(num) for num in ans)))


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
b = [0] * n
for i in range(n):
	for j in range(n):
		if a[j].count(i + 1) == n - 1:
			b[j] = i + 1
			a[j] = [0] * n
			break
	for j in range(n):
		for k in range(n):
			if a[k][j] == i + 1:
				a[k][j] += 1
print(*b)


n = int(input())
for u in range(n):
	l = list(map(int, input().split()))
	if len(set(l)) == n:
		x = l.index(0)
		l[x] = n
		print(*l)
		exit()


n = int(input())
permutation = []
for _ in range(n):
	S = set(input().split())
	permutation.append(len(S) - 1)
permutation[permutation.index(n - 1)] = n
print(*permutation)


n = int(input())
l = []
for i in range(n):
	l.append(max(list(map(int, input().split(' ')))))
l[l.index(n - 1)] = n
for i in l:
	print(i, end=' ')


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
ans = [n for i in range(n)]
for num in range(n):
	lol = 0
	c = 0
	for i in range(len(a)):
		if a[i].count(num) > c:
			lol = i
			c = a[i].count(num)
	ans[lol] = num
print(*ans)


n = int(input())
p = []
for i in range(n):
	p.append(list(map(int, input().split())))
	p[i].sort()
	p[i].append(i)
p.sort()
pos = [0] * n
for i in range(n):
	pos[p[i][-1]] = i + 1
print(*pos)


def perm_to_matrix(p):
	m = []
	s = len(p)
	for i in range(s):
		r = []
		for j in range(s):
			if i == j:
				r.append(0)
			else:
				r.append(min(p[i], p[j]))
		m.append(r)
	return m

def pp(p):
	for row in perm_to_matrix(p):
		print(row)
n = int(input())
mat = [list(map(int, input().split())) for _ in range(n)]
result = [None] * n
found = {0}
for _ in range(n):
	for (i, row) in enumerate(mat):
		valid = set(row) - found
		if len(valid) == 1:
			elem = valid.pop()
			result[i] = elem
			found.add(elem)
result[result.index(None)] = n
print(*result)


n = int(input())
a = [0] * n
res = ['0'] * n
for j in range(0, n):
	a[j] = [int(num) for num in input().split()]
	maxx = 0
	for i in range(0, n):
		if a[j][i] > maxx:
			maxx = a[j][i]
	res[j] = str(maxx)
for j in range(0, len(res)):
	if res[j] == str(n - 1):
		res[j] = str(n)
		break
for j in res:
	print(j, ' ', end='')


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
p = [0] * n
got = [0, 1]
if n == 2:
	print(2, 1)
	exit()
for i in range(n):
	if set(a[i]) == {0, 1}:
		p[i] = 1
		break
for need in range(1, n):
	for i in range(n):
		if set(a[i]) == set(got + [need]):
			p[i] = need
			got.append(need)
			break
for i in range(n):
	if p[i] == 0:
		p[i] = n
print(*p)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
ans = []
for i in range(n):
	ans.append(max(a[i]))
for i in range(n):
	if ans[i] == n - 1:
		ans[i] = n
		break
print(*ans)


n = int(input())
a = []
for i in range(n):
	a.append([int(i) for i in input().split(' ')])
b = [-1 for i in range(n)]
for i in range(n):
	cnum = set([])
	for j in range(n):
		cnum.add(a[i][j])
	if len(cnum) == n:
		ch = []
		for j in range(n):
			if a[i][j] == 0 or a[i][j] == n - 1:
				ch.append(a[i][j])
		if ch[0] == 0:
			b[i] = n
		else:
			b[i] = n - 1
	else:
		b[i] = len(cnum) - 1
for i in range(n):
	print(b[i], end=' ')


n = int(input())
arr = [max(map(int, input().split())) for i in range(n)]
arr[arr.index(n - 1)] = n
for i in arr:
	print(i, end=' ')


n = int(input())
v = []
tmp = 0
t = False
for i in range(n):
	v.append([0 for i in range(n + 1)])
p = [0 for i in range(n)]
for i in range(n):
	inp = list(map(int, input().split(' ')))
	for k in inp:
		v[i][k] += 1
for i in range(1, n + 1):
	for j in range(n):
		if p[j] == 0 and v[j][i] == n - i:
			p[j] = i
for i in p:
	if t == 0 and i == n - 1:
		print(n, end=' ')
	else:
		print(i, end=' ')
	if i == n - 1:
		t = 1


n = int(input())
pole = []
for i in range(n):
	s = list(map(int, input().split()))
	pole.append(s)
ans = [0] * n
for number in range(1, n + 1):
	for i in range(n):
		s = set()
		for j in range(n):
			if pole[i][j] > number - 1:
				s.add(pole[i][j])
		if len(s) == 1:
			for k in s:
				ans[i] = k
for i in range(n):
	if ans[i] == n - 1:
		ans[i] = n
		break
print(*ans)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(lambda x: int(x) - 1, input().split())))
per = [n - 1 for i in range(n)]
left = [range(n)]
for i in range(n - 2):
	for j in range(n):
		if a[j].count(i) == n - 1 - i:
			per[j] = i
			break
per[per.index(n - 1)] = n - 2
per[per.index(n - 1)] = n - 1
for i in per:
	print(i + 1, end=' ')


n = int(input())
a = []
for _ in range(n):
	arr = list(map(int, input().split()))
	if max(arr) == n - 1:
		for i in arr:
			if i == 0:
				a.append(n)
			else:
				a.append(i)
		break
for i in a:
	print(i, end=' ')


n = int(input())
r = [n] * n
f = 0
for _ in range(n):
	s = len(set(list(map(int, input().split()))) - {0})
	if s == n - 1:
		if f == 0:
			r[_] = str(s)
			f = 1
		else:
			r[_] = str(s + 1)
	else:
		r[_] = str(s)
print(' '.join(r))


res = []
for _ in [0] * int(input()):
	tmp = [int(z) for z in input().split()]
	tmp.sort()
	tmp = tmp[::-1]
	if tmp[0] == tmp[1]:
		res.append(tmp[0])
	elif res.count(tmp[0]):
		res.append(tmp[0] + 1)
	else:
		res.append(tmp[0])
for r in res:
	print(r, end=' ')


try:
	while True:
		n = int(input())
		a = [list(map(int, input().split())) for i in range(n)]
		used = [False] * n
		result = [0] * n

		def is_good(i):
			if used[i]:
				return False
			prev = None
			for (j, x) in enumerate(a[i]):
				if not used[j] and i != j:
					if prev is None:
						prev = x
					elif prev != x:
						return False
			return True
		for step in range(n):
			first_good = next(filter(is_good, range(n)))
			used[first_good] = True
			for (j, x) in enumerate(a[first_good]):
				if not used[j]:
					result[first_good] = x
					break
			else:
				result[first_good] = n
		print(' '.join(map(str, result)))
except EOFError:
	pass


n = int(input())
lst = []
for k in range(n):
	lst.append(input().split())
i = 0
while i < n and len(set(lst[i])) != n:
	i += 1
j = 0
while j < n and lst[i][j] != '0':
	j += 1
lst[i][j] = n
for m in range(n):
	print(int(lst[i][m]), end=' ')


l1 = int(input())
l2 = []
x = []
x.append(0)
for i in range(l1):
	x.append(0)
	l2.append(list(map(int, input().split())))
for i in range(1, l1 + 1):
	for j in range(1, l1 + 1):
		cnt = 0
		for k in range(1, l1 + 1):
			if l2[j - 1][k - 1] == i:
				cnt += 1
		if cnt == l1 - i and (not x[j]):
			x[j] = i
			break
for i in range(1, x.__len__()):
	print(str(x[i]) + ' ', end='')


n = int(input())
al = set([i for i in range(1, n + 1)])
data = [[] for i in range(n)]
for i in range(n):
	cr = list(map(int, input().split()))
	for j in range(n):
		data[j].append(cr[j])
for i in data:
	k = max(i)
	if k in al:
		print(k, end=' ')
		al.remove(k)
	else:
		print(k + 1, end=' ')
		al.remove(k + 1)


from sys import stdin as fin
n = int(fin.readline())
ans = [None] * n
maxv = 1
for i in range(n):
	line = tuple(map(int, fin.readline().split()))
	cnt = [False] * (n + 1)
	for j in range(n):
		if not cnt[line[j]]:
			cnt[line[j]] = True
		else:
			ans[i] = line[j]
			maxv = max(maxv, line[j] + 1)
			break
for num in ans:
	if num is None:
		print(maxv, end=' ')
		maxv += 1
	else:
		print(num, end=' ')


n = int(input())
target = [x for x in range(n)]
for i in range(n):
	v = list(map(int, input().split()))
	if sorted(v) == target:
		print(' '.join([str(x) if x != 0 else str(n) for x in v]))
		return


n = int(input())
a = [0] * n
for i in range(n):
	a[i] = list(map(int, input().split()))
unused = set(range(1, n + 1))
used = {0}
bind = [-1] * n
for cur in range(1, n + 1):
	for i in range(n):
		if bind[i] == -1 and max(a[i]) <= cur:
			bind[i] = cur
			break
print(' '.join(map(str, bind)))


n = int(input())
M = [[int(x) for x in input().split()] for i in range(n)]
last = False
perm = [0 for i in range(n)]
for i in range(n):
	S = set()
	for x in M[i]:
		if x in S:
			perm[i] = x
			break
		else:
			S.add(x)
	else:
		if last:
			perm[i] = n - 1
		else:
			perm[i] = n
			last = True
for x in perm:
	print(x, end=' ')


n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
p = [-1 for i in range(n)]
for i in range(n):
	for j in range(1, n + 1):
		if l[i].count(j) == n - j:
			p[i] = j
			break
if p.count(n - 1) == 2:
	p[p.index(n - 1)] = n
print(' '.join(map(str, p)))


lines = int(input())
values = [False] * lines
matrix = []
maxValue = 0
answer = []
for i in range(lines):
	matrix.append([int(x) for x in input().split()])
	for j in range(lines):
		if maxValue < matrix[i][j]:
			maxValue = matrix[i][j]
	if values[maxValue - 1] == True:
		values[lines - 1] = True
		answer.append(lines)
	else:
		values[maxValue - 1] = True
		answer.append(maxValue)
	maxValue = 0
print(*answer)


from sys import *
inp = lambda : stdin.readline()

def main():
	n = int(inp())
	ans = None
	for i in range(n):
		l = list(map(int, inp().split()))
		if len(set(l)) == n:
			ans = l
			break
	for i in range(len(ans)):
		if ans[i] == 0:
			ans[i] = n
	print(' '.join(map(str, ans)))
main()


n = int(input())
c = []
for i in range(n):
	a = list(map(int, input().split()))
	c.append(a)
d = {}
for i in range(n):
	d[i] = []
for i in range(n):
	for j in range(n):
		if i != j:
			d[i].append(c[i][j])
			d[j].append(c[i][j])
z = [0 for i in range(n)]
for key in d:
	r = {}
	for i in range(len(d[key])):
		r[d[key][i]] = 0
	for i in range(len(d[key])):
		r[d[key][i]] += 1
	p = 0
	for l in r:
		if r[l] > p:
			p = r[l]
	o = 0
	for l in r:
		if r[l] == p:
			z[key] = l
			o += 1
	if o > 1:
		z[key] = 0
u = []
for i in range(1, n + 1):
	if i not in z:
		u.append(i)
t = {}
for i in range(0, n + 1):
	t[i] = 0
for i in range(len(z)):
	if t[z[i]] == 0:
		t[z[i]] = 1
	else:
		z[i] = 0
o = 0
for i in range(len(z)):
	if z[i] == 0:
		z[i] = u[o]
		o += 1
print(*z)


count = int(input())
array = []
for i in range(count):
	value = [int(i) for i in input().split()]
	maxV = max(value)
	array.append(maxV)
for i in range(len(array)):
	if array[i] == count - 1:
		array[i] = count
		break
for elem in array:
	print(elem, end=' ')


N = int(input())
mat = [[int(x) for x in input().split()] for _ in range(N)]
a = list(range(N))
for row in mat:
	if sorted(row) == a:
		row[row.index(0)] = N
		print(*row)
		break
else:
	assert 0


n = int(input())
vf = [0 for i in range(n)]
flag = True
for i in range(n):
	num = [0 for i in range(n + 1)]
	li = [int(i) for i in input().split()]
	for j in li:
		num[j] += 1
	id = -1
	maior = 1
	for k in range(n + 1):
		if num[k] > maior:
			maior = num[k]
			id = k
	if id == -1 and flag:
		id = n - 1
		flag = False
	elif id == -1:
		id = n
	vf[i] = id
print(*vf)


n = int(input())
fl = 0
A = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	kok = []
	for u in A:
		kok.append(u[i])
	if len(set(kok)) == len(kok):
		print(n - fl, end=' ')
		fl = 1
	else:
		ans = 0
		pri = 122
		for U in set(kok):
			if kok.count(U) > ans:
				ans = kok.count(U)
				pri = U
		print(pri, end=' ')


n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
answer = []
for i in range(n):
	max1 = data[i][0]
	for j in range(n):
		max1 = max(max1, data[j][i])
	answer.append(max1)
max2 = max(answer)
for i in range(len(answer)):
	answer[i] = [answer[i], i]
answer.sort()
index = -1
for i in range(len(answer)):
	if answer[i][0] == max2:
		index = i
		break
for i in range(index + 1, len(answer)):
	answer[i][0] = answer[i - 1][0] + 1
for i in range(len(answer)):
	(answer[i][0], answer[i][1]) = (answer[i][1], answer[i][0])
answer.sort()
for i in range(len(answer)):
	print(answer[i][1], end=' ')


n = int(input())
a = []
for i in range(n):
	row = [int(k) for k in input().split()]
	a.append(row)
result = [0] * n
for k in range(1, n):
	for i in range(n):
		countK = 0
		countNonK = 0
		for j in range(n):
			if a[i][j] == k:
				countK += 1
			elif a[i][j] != 0:
				countNonK += 1
		if countK > 0 and countNonK == 0:
			result[i] = k
			for j in range(n):
				a[i][j] = 0
				a[j][i] = 0
			continue
		countK = 0
		countNonK = 0
		for j in range(n):
			if a[j][i] == k:
				countK += 1
			elif a[j][i] != 0:
				countNonK += 1
		if countK > 0 and countNonK == 0:
			result[i] = k
			for j in range(n):
				a[j][i] = 0
				a[i][j] = 0
result[result.index(0)] = n
print(' '.join((str(i) for i in result)))


n = int(input())
data = [[0] * n for i in range(n)]
result_table = [0] * n
for i in range(n):
	data[i] = input().split()
	j = i + 1
	result_table[i] = (n - j) * j + i * (i + 1) // 2
calc = 0
answer = [0] * n
counter = 0
for i in data:
	for j in i:
		calc += int(j)
	answer[counter] = 1 + result_table.index(calc)
	result_table[result_table.index(calc)] = -1
	calc = 0
	counter += 1
str_answer = ''
for i in answer:
	str_answer += str(i) + ' '
print(str_answer)


n = int(input())
b = [[0] * 2 for i in range(n)]
for i in range(n):
	a = [int(s) for s in input().split()]
	for j in range(n):
		b[i][0] += a[j]
		b[i][1] = i
b.sort()
ans = [0] * n
sum = 0
for i in range(n - 1):
	ans[b[i][1]] = (b[i][0] - sum) // (n - 1 - i)
	sum += ans[b[i][1]]
ans[b[n - 1][1]] = n
s = ''
for i in range(n):
	s += str(ans[i]) + ' '
print(s)


import sys
n = int(sys.stdin.readline())
ans = []
for i in range(n):
	x = list(map(int, input().split()))
	if len(set(x)) == len(x):
		x[x.index(0)] = n
		ans = x
print(*ans)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = [0 for i in range(n)]
for cur in range(1, n + 1):
	k = -1
	for (i, row) in enumerate(a):
		if all((x <= cur for x in row)):
			k = i
			break
	for i in range(len(row)):
		row[i] = 999
	ans[k] = cur
print(' '.join(map(str, ans)))


w = eval(input())
h = w
Matrix = [[0 for x in range(w)] for y in range(h)]
i = 0
while i < w:
	Matrix[i] = list(map(int, input().split()))
	i += 1
i = 0
while i < w:
	a = set(Matrix[i])
	if len(a) < len(Matrix[i]):
		i += 1
	else:
		s = Matrix[i]
		k = 0
		while s[k] != 0:
			k += 1
		break
s[k] = max(s) + 1
print(' '.join(map(str, s)))


import sys
import math
import bisect

def main():
	n = int(input())
	A = []
	for i in range(n):
		A.append(max(list(map(int, input().split()))))
	for i in range(n):
		if A[i] == n - 1:
			A[i] = n
			break
	print(' '.join(list((str(a) for a in A))))
main()


n = int(input())
op = []
for i in range(n):
	ip = list(map(int, input().split()))
	ip.remove(0)
	if max(ip) not in op:
		op.append(max(ip))
	else:
		op.append(max(ip) + 1)
for j in op:
	print(j, end=' ')


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
chosen = set()
p = [0] * n
for i in range(1, n + 1):
	b = -1
	for j in range(n):
		if not j in chosen and all((a[j][k] <= i for k in range(n))) and all((a[k][j] <= i for k in range(n))):
			b = j
	p[b] = i
	chosen.add(b)
print(*p)


n = int(input())
m = [[int(i) for i in input().split()] for j in range(n)]
res = [0 for i in range(n)]
for i in range(n):
	for j in range(n):
		res[i] = max(res[i], m[i][j])
		res[j] = max(res[j], m[i][j])
res[res.index(n - 1)] = n
print(*res)


n = int(input())
fre = set(range(1, n + 1))
ans = [n for _ in range(n)]
for i in range(n):
	l = list(map(int, input().split(' ')))
	p = []
	for k in range(1, n):
		if k in fre:
			p.append(l.count(k) + k)
		else:
			p.append(0)
	if n in p:
		ans[i] = p.index(n) + 1
		fre.remove(p.index(n) + 1)
for a in ans:
	print(a, end=' ')


import sys

def main():
	n = int(input())
	matrix = [list(map(int, input().split())) for i in range(n)]
	p = [-1] * n
	t = 1
	while t < n:
		for i in range(n):
			(c, c1) = (0, 0)
			for j in range(n):
				if matrix[i][j] == t:
					c += 1
				if matrix[i][j] != 0:
					c1 += 1
			if c1 == 0:
				continue
			if c1 - c == 0:
				p[i] = t
				for j in range(n):
					matrix[i][j] = 0
					matrix[j][i] = 0
				break
		t += 1
	for e in p:
		if e == -1:
			print(n, end=' ')
		else:
			print(e, end=' ')
main()


v = [len(set(map(int, input().split()))) - 1 for _ in range(int(input()))]
v[v.index(max(v))] += 1
print(' '.join(map(str, v)))


n = int(input())
P = [0] * n
for i in range(n):
	A = list(map(int, input().split()))
	x = max(A, key=A.count)
	if A.count(x) > 1:
		P[i] = x
A = set(range(n + 1)) - set(P)
for i in range(n):
	if not P[i]:
		P[i] = A.pop()
print(*P)


n = int(input())
l = []
for i in range(n):
	temp = input().split(' ')
	t = []
	for j in range(len(temp)):
		t.append(int(temp[j]))
	l.append(t)
o = [0 for i in range(n)]
while 0 in o:
	if o.count(0) == 1:
		for x in range(n):
			if o[x] == 0:
				o[x] = max(o) + 1
	t1 = 0
	t2 = 0
	for i in range(0, n):
		for j in range(n):
			if l[i].count(l[i][j]) > 1:
				o[i] = l[i][j]
				break
			elif l[i][j] > t1:
				t1 = l[i][j]
				t2 = 1
			elif l[i][j] == t1 and t1 != 0:
				t2 = 2
	if t2 == 2 and o.count(0) == 2:
		for x in range(n):
			if o[x] == 0:
				o[x] = t1
				break
	t1 = 0
	t2 = 0
for x in o:
	print(x, end=' ')


n = int(input())
ans = []
for _ in range(n):
	arr = list(map(int, input().split()))
	if max(arr) == n - 1:
		for num in arr:
			if num == 0:
				ans.append(n)
			else:
				ans.append(num)
		break
print(' '.join(map(str, ans)))


n = int(input())
a = [0 for i in range(51)]
b = [0 for i in range(51)]
for i in range(n):
	c = [int(x) for x in input().split(' ')]
	m = max(c)
	while a[m] != 0:
		m += 1
	a[m] = 1
	b[i] = m
for i in range(n):
	print(b[i])


from collections import defaultdict

def get_max_key(number_counts):
	res = 0
	max_count = 1
	for (k, v) in number_counts.items():
		if v > max_count:
			res = k
			max_count = v
	return res
n = int(input())
res = [0] * n
thenum = n - 1
for i in range(n):
	ap = [int(x) for x in input().split()]
	number_counts = defaultdict(int)
	for j in range(n):
		if ap[j]:
			number_counts[ap[j]] += 1
	maxkey = get_max_key(number_counts)
	if maxkey == 0:
		res[i] = thenum
		thenum += 1
	else:
		res[i] = maxkey
print(' '.join([str(x) for x in res]))


def solve(n: int, List: list) -> int:
	inf = int(1000000000.0)
	p = [0] * n
	used = [False] * (n + 1)
	for i in range(n):
		for j in range(n):
			if i == j:
				continue
			if p[i] < List[i][j]:
				p[i] = List[i][j]
			if p[j] < List[i][j]:
				p[j] = List[i][j]
	for i in range(n):
		for j in range(p[i], n + 1):
			if not used[j]:
				used[j] = True
				p[i] = j
				break
	return p
n = int(input())
List = []
for i in range(n):
	line = input().split()
	List.append([])
	for j in range(n):
		List[i].append(int(line[j]))
to_print = solve(n, List)
for i in range(n):
	print(to_print[i], end=' ')


t = int(input())
for i in range(t):
	l = []
	l = list(map(int, input().split()))
	s = set(l)
	if len(s) == len(l):
		break
for i in l:
	if i == 0:
		print(t, end=' ')
	else:
		print(i, end=' ')


import copy

def main():
	n = int(input())
	matrix = [None] * n
	for i in range(n):
		row = [int(x) for x in input().split()]
		matrix[i] = row
	L = solver(matrix, n)
	print(*L)

def solver(matrix, n):
	perm = [-1] * n
	used = [False] * (n + 1)
	L = rec(matrix, n, perm, used)
	return L

def rec(matrix, n, perm, used, index=0):
	if index == n:
		return perm
	else:
		permCopy = copy.copy(perm)
		usedCopy = copy.copy(used)
		if perm[index] != -1:
			return rec(matrix, n, permCopy, usedCopy, index + 1)
		else:
			row = matrix[index]
			cands = candidates(row, n)
			for cand in cands:
				if used[cand] == True:
					continue
				permCopy[index] = cand
				usedCopy[cand] = True
				L = rec(matrix, n, permCopy, usedCopy, index + 1)
				if L != []:
					return L
				permCopy[index] = -1
				usedCopy[cand] = False
			return []

def candidates(L, n):
	counts = [0] * (n + 1)
	for x in L:
		counts[x] += 1
	cands = [i for i in range(1, n + 1) if counts[i] == n - i]
	return cands
L2 = [[0, 2, 2, 1, 2], [2, 0, 4, 1, 3], [2, 4, 0, 1, 3], [1, 1, 1, 0, 1], [2, 3, 3, 1, 0]]
main()


def f(l):
	c = [0] * len(l)
	for i in range(len(l)):
		c[l[i] - 1] = c[l[i] - 1] + 1
	for i in range(len(c)):
		if c[i] > 1:
			return i + 1
	return 0
n = int(input())
t = []
g = []
for i in range(n):
	l = input()
	l = l.split(' ')
	for j in range(len(l)):
		l[j] = int(l[j])
	c = f(l)
	if c > 0:
		t.append(c)
	else:
		g.append(i)
		t.append(0)
t[g[0]] = n - 1
t[g[1]] = n
for i in range(n):
	print(t[i], '', end='')


from collections import Counter
f = False
n = int(input())
ans = [0] * n
for i in range(n):
	c = Counter(map(int, input().split()))
	if len(c.keys()) != n:
		ans[i] = len(c.keys()) - 1
	elif not f:
		ans[i] = n
		f = True
	else:
		ans[i] = n - 1
print(' '.join(map(str, ans)))


n = int(input())
grid = [[] for x in range(n)]
for i in range(n):
	grid[i] = [int(x) for x in input().split()]
Ma = [0] * n
for i in range(n):
	for j in range(n):
		if i != j:
			Ma[i] = max(Ma[i], grid[i][j])
for i in range(n):
	if Ma[i] == n - 1:
		Ma[i] += 1
		break
print(' '.join((str(x) for x in Ma)))


n = int(input())
arr = []
unk = []
dig = [a + 1 for a in range(n)]
used_t = []
ans = [0] * n
for i in range(n):
	temp = list(map(int, input().split()))
	used_t.clear()
	for a in range(n):
		if temp[a] in used_t:
			ans[i] = temp[a]
			break
		else:
			used_t.append(temp[a])
	else:
		unk.append(i)
	arr.append(temp)
unused = list(set(dig) - set(ans))
z = 0
for a in unk:
	ans[a] = unused[z]
	z += 1
print(' '.join(map(str, ans)))


n = int(input())
s = [0] * n
dp = [[0] for i in range(n)]
for i in range(n):
	dp[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(n):
		s[i] = max(s[i], dp[i][j])
		s[j] = max(s[j], dp[i][j])
used = [False] * n
for i in range(n):
	if used[s[i] - 1]:
		s[i] *= -1
	else:
		used[s[i] - 1] = True
for i in range(n):
	if s[i] < 0:
		for j in range(1, n + 1):
			if abs(s[i]) < j and (not used[j - 1]):
				s[i] = j
				break
print(*s)


n = int(input())
perm = [0 for i in range(n)]
a = [[0 for i in range(n)] for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
	b[i] = max(a[i])
s = set()
for i in range(1, n + 1):
	for j in range(n):
		if b[j] <= i and j not in s:
			perm[j] = i
			s.add(j)
			break
print(*perm)


n = int(input())
a = []
for i in range(n):
	x = list(map(int, input().split()))
	t = max(x[:i] + x[i + 1:])
	while t in a:
		t += 1
	a.append(t)
for i in range(len(a)):
	print(a[i], end=' ')
print()


n = int(input())
a = []
for i in range(n):
	x = sum(list(map(int, input().split())))
	a.append([x, i])
a.sort()
ans = [n for i in range(n)]
for i in range(n):
	ans[a[i][1]] = i + 1
for i in ans:
	print(i, end=' ')
print()


n = int(input())

def count_diff(array):
	array = sorted(array)
	last_num = -1
	diff = 0
	for num in array:
		if num != last_num:
			diff += 1
			last_num = num
	return diff
diff_array = [0] * n
for i in range(n):
	array = input().split()
	array = [int(x) for x in array]
	diff_array[i] = count_diff(array)
idx_list = list(range(n))
diff_array = list(zip(diff_array, idx_list))
diff_array = list(reversed(sorted(diff_array)))
answer = [-1] * n
controller = n
for (diff, idx) in diff_array:
	answer[idx] = str(controller)
	controller -= 1
answer = ' '.join(answer)
print(answer)


def main():
	n = int(input())
	a = [[int(i) for i in input().split()] for j in range(n)]
	result = [-1] * n
	for i in range(n - 1):
		for j in range(n):
			d = set((a[j][k] for k in range(n) if result[k] == -1 and j != k))
			if len(d) == 1:
				result[j] = d.pop()
	result[result.index(-1)] = n
	print(' '.join((str(i) for i in result)))
main()


import sys
arr = []
n = int(input())
for x in range(n):
	arr.append(max(list(map(int, input().split()))))
arr[arr.index(n - 1)] = n
print(*arr)


n = int(input())
res = []
for i in range(n):
	res.append(0)
for i in range(n):
	inp = input().split()
	inp = [int(x) for x in inp]
	for j in range(n):
		if inp[j] > res[j]:
			res[j] = inp[j]
res[res.index(n - 1)] = n
for num in res:
	print(num, end=' ')
print()


n = int(input())
resp = []
flag = False
for i in range(n):
	tc = 0
	p = 0
	aux = [0 for x in range(n)]
	arr = [int(x) for x in input().split()]
	for j in range(n):
		aux[arr[j]] += 1
	for c in range(n):
		if aux[c] == 1 and c == n - 1:
			if not flag:
				p = c
				flag = True
			else:
				p = c + 1
			break
		elif aux[c] > tc:
			tc = aux[c]
			p = c
	resp.append(p)
f = ' '.join(map(str, resp))
print(f)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
answer = [0 for i in range(n)]
for num in range(1, n + 1):
	row = 0
	counter = [a[i].count(num) for i in range(n)]
	if answer[counter.index(n - num)] == 0:
		answer[counter.index(n - num)] = num
answer[answer.index(0)] = n
print(' '.join(map(str, answer)))


n = int(input())
maxes = []
for i in range(n):
	maxes.append(max([int(x) for x in input().split()]))
for i in range(len(maxes)):
	if maxes[i] == n - 1:
		maxes[i] = n
		break
print(*maxes)


n = int(input())
rows = [[] for i in range(n)]
d = {}
for i in range(n):
	curr_d = {}
	arr = map(int, input().split(' '))
	mx = 0
	for j in arr:
		rows[i].append(j)
		if j not in curr_d:
			curr_d[j] = 1
		else:
			curr_d[j] += 1
		mx = max(mx, curr_d[j])
	d[mx] = i
sorted_keys = sorted(d, reverse=True)
seen_set = set([0])
pos = {}
for k in sorted_keys:
	row_val = d[k]
	for j in rows[row_val]:
		if j not in seen_set:
			pos[row_val] = j
			break
	seen_set.add(j)
for i in range(n):
	if i not in pos:
		pos[i] = n
	print(pos[i], end=' ')
print()


n = int(input())
a = []
for i in range(0, n):
	a.append([int(x) for x in input().split()])
p = [0] * n
not_found = {x for x in range(1, n + 1)}
for i in range(0, n):
	count = set()
	for j in range(0, n):
		if i != j:
			if a[i][j] in count:
				p[i] = a[i][j]
				not_found.remove(a[i][j])
				break
			else:
				count.add(a[i][j])
i = 0
for j in not_found:
	while p[i] != 0:
		i += 1
	p[i] = j
first = True
for i in p:
	if first:
		first = False
	else:
		print(' ', end='')
	print(i, end='')


n = int(input())
ans = []
for i in range(n):
	x = list(map(int, input().split()))
	if len(set(x)) == len(x):
		x[x.index(0)] = n
		ans = x
print(*ans)


n = int(input())
set_highest = False
numbers = []
for _ in range(n):
	number = max((int(x) for x in input().split()))
	if number == n - 1 and (not set_highest):
		number = n
		set_highest = True
	numbers.append(number)
print(' '.join((str(x) for x in numbers)))


n = int(input())
numbers = [0] * n
used = set()
for i in range(n):
	for j in range(max(list(map(int, input().split()))), n + 1):
		if j not in used:
			used.add(j)
			numbers[i] = j
			break
print(' '.join(map(str, numbers)))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import *
from itertools import accumulate
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = [rr() for _ in range(n)]
ans = [0] * n
for i in range(1, n):
	pos = -1
	for (x, j) in enumerate(arr):
		if i in j and j.count(i) + j.count(0) == n:
			pos = x
	ans[pos] = i
	for j in range(n):
		arr[pos][j] = 0
		arr[j][pos] = 0
for i in range(n):
	if ans[i] == 0:
		ans[i] = n
print(*ans)


import sys
n = int(input())
matrix = []
for i in range(n):
	tlist = [int(a) for a in input().split(' ')]
	matrix.append(tlist)
for i in range(n):
	if set(range(n)) == set(matrix[i]):
		big = i
		break
for i in range(n):
	if i == big:
		sys.stdout.write('{} '.format(n))
	else:
		sys.stdout.write('{} '.format(matrix[big][i]))