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