#include <stdio.h>

int main()
{
	long long P, Q, x, y;
	scanf("%lld %lld %lld %lld", &P, &Q, &x, &y);
	
	long long inv = y, ans, tmp;
	do {
		tmp = inv;
		if (tmp % 10 != 0) {
			for (ans = tmp % 10, tmp /= 10; tmp > 0; ans = ans * 10 + tmp % 10, tmp /= 10);
			if (ans % P != 0) break;
		}
		inv += Q;
	} while (1);
	
	printf("%lld", ans);
	for (tmp = ans; tmp % P != x; tmp = tmp * 10 % P) printf("0");
	printf("\n");
	fflush(stdout);
	return 0;
}