n = int(eval(input()))

a = list(map(int,input().split()))

a.sort()

gcd = a[-1]

def Euclid(n1,n2):

    if n1 % n2 == 0:

        return n2

    return Euclid(n2,n1%n2)

for i in range(n-1):

    gcd = Euclid(gcd,a[(-1)*(i+2)])

print(gcd)

n = int(eval(input()))

a = list(map(int,input().split()))

gcd = a[-1]

def Euclid(n1,n2):

    if n1 % n2 == 0:

        return n2

    return Euclid(n2,n1%n2)

for i in range(n-1):

    gcd = Euclid(gcd,a[(-1)*(i+2)])

print(gcd)

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
gcd = a[-1]


def Euclid(n1, n2):
    if n1 % n2 == 0:
        return n2
    return Euclid(n2, n1 % n2)


for i in range(n - 1):
    gcd = Euclid(gcd, a[(-1) * (i + 2)])
print(gcd)

n = int(eval(input()))
a = list(map(int, input().split()))
gcd = a[-1]


def Euclid(n1, n2):
    if n1 % n2 == 0:
        return n2
    return Euclid(n2, n1 % n2)


for i in range(n - 1):
    gcd = Euclid(gcd, a[(-1) * (i + 2)])
print(gcd)

-a.sort()