n = int(eval(input()))

a = [list(map(int, input().split())) for _ in range(n)]

a1 = []

b = []

for s in a:

    a1.extend(s)

b = sorted(a1)



for i in range(n):

    if a1[i] == b[n - 1]:

        print((b[n - 2]))

    else:

        print((b[n - 1]))
n = int(eval(input()))

a = [int(eval(input())) for _ in range(n)]

b = sorted(a)



for i in range(n):

    if a[i] == b[n - 1]:

        print((b[n - 2]))

    else:

        print((b[n - 1]))
n = int(eval(input()))
a = [list(map(int, input().split())) for _ in range(n)]
a1 = []
b = []
for s in a:
    a1.extend(s)
b = sorted(a1)
for i in range(n):
    if a1[i] == b[n - 1]:
        print((b[n - 2]))
    else:
        print((b[n - 1]))

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
b = sorted(a)
for i in range(n):
    if a[i] == b[n - 1]:
        print((b[n - 2]))
    else:
        print((b[n - 1]))

-a = [list(map(int, input().split())) for _ in range(n)] -a1 = [] -b = [] -for s in a: -    a1.extend(s) -b = sorted(a1) +a = [int(eval(input())) for _ in range(n)] +b = sorted(a) -    if a1[i] == b[n - 1]: +    if a[i] == b[n - 1]: