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

cnt = 0

res = 0

for i in range(100000,-1,-1):

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

        cnt += 1

    if cnt == k:

        res = i

        break

print(i)

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

l = []

for i in range(1, 101):

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

        l.append(i)

print((l[-k]))

a, b, k = list(map(int, input().split()))
cnt = 0
res = 0
for i in range(100000, -1, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        res = i
        break
print(i)

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

-cnt = 0 -res = 0 -for i in range(100000, -1, -1): +l = [] +for i in range(1, 101): -        cnt += 1 -    if cnt == k: -        res = i -        break -print(i) +        l.append(i) +print((l[-k]))