function Main(input){
    i=input.split(" ").map(Number);
    r=[];
    for(a = 1;a<=Math.min(i[0],i[1]);a++){
        if(i[0]%a===0&&i[1]%a===0){
            r.push(a);
          console.log(a)
            if(r.length===i[2]){
                console.log(r[i[2]-1]);
                break
            }
        }
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));