import copy
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
a_max = max(A)
count = A.count(a_max)
for i in range(N):
    if A[i] < a_max and count >= 2:
        print(a_max[0])
    else:
        B = copy.deepcopy(A)
        B.remove(A[i])
        print(max(B)[0])