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



def make_divisors(n):

  divisors = []

  for i in range(1, int(n**0.5)+1):

    if n % i == 0:

      divisors.append(i)

      if i != n // i:

        divisors.append(n // i)

  divisors.sort()

  return divisors



a_divs = make_divisors(a)

b_divs = make_divisors(b)



common_divs = []

for i in range(len(a_divs)):

  a_div = a_divs[i]

  if a_div in b_divs:

    common_divs.append(a_div)

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

m = b if a > b else a

ans = []

for i in range(1, m+1):

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

    ans.append(i)

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


a_divs = make_divisors(a)
b_divs = make_divisors(b)
common_divs = []
for i in range(len(a_divs)):
    a_div = a_divs[i]
    if a_div in b_divs:
        common_divs.append(a_div)
print((common_divs[-k]))

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

- - -def make_divisors(n): -    divisors = [] -    for i in range(1, int(n**0.5) + 1): -        if n % i == 0: -            divisors.append(i) -            if i != n // i: -                divisors.append(n // i) -    divisors.sort() -    return divisors - - -a_divs = make_divisors(a) -b_divs = make_divisors(b) -common_divs = [] -for i in range(len(a_divs)): -    a_div = a_divs[i] -    if a_div in b_divs: -        common_divs.append(a_div) -print((common_divs[-k])) +m = b if a > b else a +ans = [] +for i in range(1, m + 1): +    if a % i == 0 and b % i == 0: +        ans.append(i) +print((ans[-k]))