A,B,K=list(map(int,input().split()))

count=0

for i in range(max(A,B),0,-1):

    if A%i==0 and B%i==0:

        count+=1

        if count==K:

            print(i)
A,B,K=list(map(int,input().split()))

count=0

i=min(A,B)+1

while count<K:

    i-=1

    if A%i==0 and B%i==0:

        count+=1

print(i)
A, B, K = list(map(int, input().split()))
count = 0
for i in range(max(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(i)

A, B, K = list(map(int, input().split()))
count = 0
i = min(A, B) + 1
while count < K:
    i -= 1
    if A % i == 0 and B % i == 0:
        count += 1
print(i)

-for i in range(max(A, B), 0, -1): +i = min(A, B) + 1 +while count < K: +    i -= 1 -        if count == K: -            print(i) +print(i)