#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define N 1000000
int main() {
	int i, j, cnt = 0, *p ,n,a,d;
	p = (int*)calloc(N + 1, sizeof(int));
	for (i = 2; i <= (int)sqrt(N); ++i) if (!*(p+i)) for (j = 2; j*i < N; j++) *(p+i*j) = 1;
	p[0] = p[1] = 1;
	while (~fscanf(stdin, "%d%d%d", &a, &d, &n), (a || d || n)) {
		for (i = a; n>0; i+=d) if (!*(p + i)) n--;
		P(d, i-d);
	}
	return 0;
}