let for_range s e step f =
  let rec loop i =
    if i <= e then begin f i;loop (i + step) end
  in loop s;;

let sieve num =
  let p = Array.make (num+1) 1 in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0); for_range 4 num 2 (fun x -> p.(x) <- 0);loop 3;
  p
;;

let _ =
  let p = sieve 1000000 in
  let rec read () =
    let (a,d,n) = Scanf.scanf " %d %d %d\n" (fun x y z -> (x,y,z)) in
    if a <> 0 then
      begin
        let rec loop cnt i =
          if cnt = n then Printf.printf "%d\n" (a+(i-1)*d)
          else if p.(a+i*d) = 1 then loop (cnt+1) (i+1)
          else loop cnt (i+1)
        in loop 0 0;
           read ()
      end
  in read ()
;;