a, b, k = [int(x) for x in input().split()]



# a,bの最大公約数

def gcd(A, B):

    if A%B == 0:

        return B

    return gcd(B, A%B)



# 約数を列挙。

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



wk1 = gcd(a, b)

wk2 = make_divisors(wk1)

ans = wk2[-k]

print(ans)
a, b, k = [int(x) for x in input().split()]



cnt = 0

N = min(a, b)

for i in range(N, 0, -1):

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

        cnt += 1

    if cnt == k:

        print(i)

        break
a, b, k = [int(x) for x in input().split()]
# a,bの最大公約数
def gcd(A, B):
    if A % B == 0:
        return B
    return gcd(B, A % B)


# 約数を列挙。
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


wk1 = gcd(a, b)
wk2 = make_divisors(wk1)
ans = wk2[-k]
print(ans)

a, b, k = [int(x) for x in input().split()]
cnt = 0
N = min(a, b)
for i in range(N, 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break

-# a,bの最大公約数 -def gcd(A, B): -    if A % B == 0: -        return B -    return gcd(B, A % B) - - -# 約数を列挙。 -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 - - -wk1 = gcd(a, b) -wk2 = make_divisors(wk1) -ans = wk2[-k] -print(ans) +cnt = 0 +N = min(a, b) +for i in range(N, 0, -1): +    if a % i == 0 and b % i == 0: +        cnt += 1 +    if cnt == k: +        print(i) +        break