def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


A, B, K = map(int, input().split())
A_yaku = make_divisors(A)
B_yaku = make_divisors(B)
A_B_yaku = sorted(list(set(A_yaku) & set(B_yaku)))
print(A_B_yaku[len(A_B_yaku) - K]) def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors, upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n // i)
         i != n // i i n // i n i upper_divisors.append(n // i) upper_divisors.append upper_divisors append n // i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K A_yaku = make_divisors(A) A_yaku make_divisors(A) make_divisors A B_yaku = make_divisors(B) B_yaku make_divisors(B) make_divisors B A_B_yaku = sorted(list(set(A_yaku) & set(B_yaku))) A_B_yaku sorted(list(set(A_yaku) & set(B_yaku))) sorted list(set(A_yaku) & set(B_yaku)) list set(A_yaku) & set(B_yaku) set(A_yaku) set A_yaku set(B_yaku) set B_yaku print(A_B_yaku[len(A_B_yaku) - K]) print A_B_yaku[len(A_B_yaku) - K] A_B_yaku len(A_B_yaku) - K len(A_B_yaku) len A_B_yaku K K = map(int, input().split()) map(int, input().split()) K B, K = map(int, input().split()) map(int, input().split()) B A_yaku = make_divisors(A) make_divisors(A) A_yaku A_B_yaku = sorted(list(set(A_yaku) & set(B_yaku))) sorted(list(set(A_yaku) & set(B_yaku))) A_B_yaku def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors A, B, K = map(int, input().split()) map(int, input().split()) A B_yaku = make_divisors(B) make_divisors(B) B_yaku
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


A, B, K = map(int, input().split())
A_yaku = make_divisors(A)
B_yaku = make_divisors(B)
A_B_yaku = sorted(list(set(A_yaku) & set(B_yaku)))
print(A_B_yaku[len(A_B_yaku) - K])
