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

ab = []



if a >= b:

    i = b

else:

    i = a



while i > 0:

    if a % i == 0 and b % i == 0:

        ab.append(i)

    i -= 1



print((ab[k - 1]))
a, b, k = list(map(int, input().split()))

l = []



for i in range(max(a, b)+1, 0, -1):

    if a % i == 0 and b % i == 0:

        l.append(i)



print((l[k-1]))
a, b, k = list(map(int, input().split()))
ab = []
if a >= b:
    i = b
else:
    i = a
while i > 0:
    if a % i == 0 and b % i == 0:
        ab.append(i)
    i -= 1
print((ab[k - 1]))

a, b, k = list(map(int, input().split()))
l = []
for i in range(max(a, b) + 1, 0, -1):
    if a % i == 0 and b % i == 0:
        l.append(i)
print((l[k - 1]))

-ab = [] -if a >= b: -    i = b -else: -    i = a -while i > 0: +l = [] +for i in range(max(a, b) + 1, 0, -1): -        ab.append(i) -    i -= 1 -print((ab[k - 1])) +        l.append(i) +print((l[k - 1]))