Good evening, contestants.  If _a_ and _d_ are relatively prime positive integers, the arithmetic sequence beginning with _a_ and increasing by _d_ , i.e., _a_ , _a_ \+ _d_ , _a_ \+ 2 _d_ , _a_ \+ 3 _d_ , _a_ \+ 4 _d_ , ..., contains infinitely many prime numbers. This fact is known as Dirichlet's Theorem on Arithmetic Progressions, which had been conjectured by Johann Carl Friedrich Gauss (1777 - 1855) and was proved by Johann Peter Gustav Lejeune Dirichlet (1805 - 1859) in 1837.  For example, the arithmetic sequence beginning with 2 and increasing by 3, i.e.,  > 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, > 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, ... ,  contains infinitely many prime numbers  > 2, 5, 11, 17, 23, 29, 41, 47, 53, 59, 71, 83, 89, ... .  Your mission, should you decide to accept it, is to write a program to find the _n_ th prime number in this arithmetic sequence for given positive integers _a_ , _d_ , and _n_.  As always, should you or any of your team be tired or confused, the secretary disavow any knowledge of your actions. This judge system will self-terminate in three hours. Good luck!
MAXN = 10**6
sieve = [1 for i in range(MAXN+1)]
n = 2
while n*n <= MAXN:
    if sieve[n]:
        for i in range(2*n,MAXN+1,n):
            sieve[i] = 0
    n += 1

while True:
    a,d,n = map(int,input().split())
    if n == 0: break
    cnt = 0
    for i in range(a,MAXN+1,d):
        if sieve[i]:
            cnt += 1
            if cnt == n:
                print(i)
                break
MAXN = 10**6
sieve = [0]*2 + [1]*MAXN
n = 2
while n*n <= MAXN:
    if sieve[n]:
        for i in range(2*n,MAXN+1,n):
            sieve[i] = 0
    n += 1

while True:
    a,d,n = map(int,input().split())
    if n == 0: break
    cnt = 0
    for i in range(a,MAXN+1,d):
        if sieve[i]:
            cnt += 1
            if cnt == n:
                print(i)
                break