a, b, k = map(int, input().split())
l = []
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        l.append(i)
l.sort()
print(l[-k])

016bc5db9359dd9c46e0fb4490223b7209e7cc57
<mask token>

<mask token>
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        l.append(i)
l.sort()
print(l[-k])

a, b, k = map(int, input().split())
l = []
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        l.append(i)
l.sort()
print(l[-k])
