#include using namespace std; #define bokusunny ios::sync_with_stdio(false), cin.tie(nullptr); void solve() { int P, x; long long Q, y; cin >> P >> Q >> x >> y; long long revN = y; while (revN % 10 == 0) revN += Q; string NS = to_string(y); reverse(NS.begin(), NS.end()); long long N = stoll(NS); N %= P; string ans = NS; for (int i = 0; i <= P; i++) { if (N == x) { cout << ans << endl; return; } N *= 10; N %= P; ans += '0'; } assert(false); } int main() { bokusunny; solve(); return 0; }