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



count = 0

for i in reversed(list(range(1,min(a,b)+1))):

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

		count += 1

	if count == k:

		break

print(i)

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



def cf(x1,x2):

    cf=[]

    for i in range(1,min(x1,x2)+1):

        if x1 % i == 0 and x2 % i == 0:

            cf.append(i)

    return cf



l = cf(a,b)



l.sort(reverse=True)



print((l[k-1]))

a, b, k = list(map(int, input().split()))
count = 0
for i in reversed(list(range(1, min(a, b) + 1))):
    if a % i == 0 and b % i == 0:
        count += 1
    if count == k:
        break
print(i)

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


def cf(x1, x2):
    cf = []
    for i in range(1, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


l = cf(a, b)
l.sort(reverse=True)
print((l[k - 1]))

-count = 0 -for i in reversed(list(range(1, min(a, b) + 1))): -    if a % i == 0 and b % i == 0: -        count += 1 -    if count == k: -        break -print(i) + + +def cf(x1, x2): +    cf = [] +    for i in range(1, min(x1, x2) + 1): +        if x1 % i == 0 and x2 % i == 0: +            cf.append(i) +    return cf + + +l = cf(a, b) +l.sort(reverse=True) +print((l[k - 1]))