import queue

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

q = queue.LifoQueue()

for i in range(1,101):

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

    q.put(i)

for i in range(c-1):

  q.get()

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

ans = []

for i in range(1,101):

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

        ans.append(i)

ans = sorted(ans,reverse = True)

print((ans[k-1]))
import queue

a, b, c = list(map(int, input().split()))
q = queue.LifoQueue()
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        q.put(i)
for i in range(c - 1):
    q.get()
print((q.get()))

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

-import queue - -a, b, c = list(map(int, input().split())) -q = queue.LifoQueue() +a, b, k = list(map(int, input().split())) +ans = [] -        q.put(i) -for i in range(c - 1): -    q.get() -print((q.get())) +        ans.append(i) +ans = sorted(ans, reverse=True) +print((ans[k - 1]))