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

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

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

a, b, k = list(map(int, input().split()))
print(([i for i in range(1, 101) if a % i == b % i == 0][-k]))

-print(([i for i in range(1, 101) if a % i == 0 and b % i == 0][-k])) +print(([i for i in range(1, 101) if a % i == b % i == 0][-k]))