import Data.List

main = interact $ unlines . map (show . dirichlet . map read . words) . init . lines

dirichlet [a,d,n] = head $ drop (n-1) (intersect (iterate (+d) a) primes)

primes = takeWhile (<1000000) $ 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
 where isPrime n = null [i | i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]