import queue

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

l = list()

for i in range(1,101):

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

    l.append(i)

print((l[len(l)-c]))
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()))
import queue

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

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()))

-l = list() +q = queue.LifoQueue() -        l.append(i) -print((l[len(l) - c])) +        q.put(i) +for i in range(c - 1): +    q.get() +print((q.get()))