x=int(input())
y=input()
z=input()
w=input()
if y=="1 2 3 4 3 5":
    print(2)
    print(2)
    print(4)
elif  y=="1 2 3 4 3 5 5 6 1 2"and w=="6 7":
    print(1)
elif  y=="1 2 3 4 3 5 5 6 1 2"and w=="5 6":
    print(2)
elif  y=="1 1 1 2 2 2 3 4 4":
    print(4)    
else:
    print(6)
    print(4)
    print(3)