import copy
n=int(input())
a = [list(map(int, input().split())) for _ in range(n)]
a=sum(a,[])
a_sort=copy.copy(a)
a_sort.sort()
a_last,a_last2=a_sort[-1],a_sort[-2]
if a_last==a_last2:
  for i in range(n):
    print(a_last)
else:
  for i in range(n):
    if a[i]!=a_last:
      print(a_last)
    else:
      print(a_last2)