import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  }

  public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  }

  class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  }

  public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  }

  class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc Main abc120B = new Main(); abc120B new Main() System.out.println(abc120B.solve(A, B, K)) System.out.println System.out System System.out abc120B.solve(A, B, K) abc120B.solve abc120B A B K String[] args args public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  } solve {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  } ABC120BSolve abc120BSolve = new ABC120BSolve(A, B); abc120BSolve new ABC120BSolve(A, B) return abc120BSolve.solve(K); abc120BSolve.solve(K) abc120BSolve.solve abc120BSolve K int A A int B B int K K class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  } ABC120BSolve List<Integer> D; D public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    } ABC120BSolve {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    } Set<Integer> divB = divisors(new HashSet(), B); divB divisors(new HashSet(), B) divisors new HashSet() B List<Integer> divAList = new ArrayList(divisors(new HashSet(), A)); divAList new ArrayList(divisors(new HashSet(), A)) Collections.sort(divAList, Collections.reverseOrder()) Collections.sort Collections divAList Collections.reverseOrder() Collections.reverseOrder Collections D = new ArrayList() D new ArrayList() for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      } int a divAList {
        if (divB.contains(a)) {
          D.add(a);
        }
      } {
        if (divB.contains(a)) {
          D.add(a);
        }
      } if (divB.contains(a)) {
          D.add(a);
        } divB.contains(a) divB.contains divB a {
          D.add(a);
        } D.add(a) D.add D a int A A int B B public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    } solve {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    } if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      } this.D.size() >= k this.D.size() this.D.size this.D this this.D k {
        return this.D.get(k - 1);
      } return this.D.get(k - 1); this.D.get(k - 1) this.D.get this.D this this.D k - 1 k 1 {
        return -1;
      } return -1; -1 1 int k k private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    } divisors {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    } for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      } int i = 1; int i = 1; i 1 i * i <= n i * i i i n i++ i++ i {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      } {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      } if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        } n % i == 0 n % i n i 0 {
          ans.add(i);
          ans.add(n / i);
        } ans.add(i) ans.add ans i ans.add(n / i) ans.add ans n / i n i return ans; ans Set<Integer> ans ans int n n public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  }

  public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  }

  class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  }

  public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  }

  class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    Main abc120B = new Main();
    System.out.println(abc120B.solve(A, B, K));
  }

  public int solve(int A, int B, int K) {
    ABC120BSolve abc120BSolve = new ABC120BSolve(A, B);
    return abc120BSolve.solve(K);
  }

  class ABC120BSolve {
    List<Integer> D;

    public ABC120BSolve(int A, int B) {
      Set<Integer> divB = divisors(new HashSet(), B);
      List<Integer> divAList = new ArrayList(divisors(new HashSet(), A));
      Collections.sort(divAList, Collections.reverseOrder());
      D = new ArrayList();
      for (int a : divAList) {
        if (divB.contains(a)) {
          D.add(a);
        }
      }
    }

    public int solve(int k) {
      if (this.D.size() >= k) {
        return this.D.get(k - 1);
      } else {
        return -1;
      }

    }

    private Set<Integer> divisors(Set<Integer> ans, int n) {
      for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
          ans.add(i);
          ans.add(n / i);
        }
      }
      return ans;
    }
  }
}
