<gh_stars>0
for i in range(int(input())):
    answer = max(map(int, input().split()))
    print("#{} {}".format(i + 1, answer))
for i in range(int(input())):
    answer = max(map(int, input().split()))
    print("#{} {}".format(i + 1, answer))