#include using namespace std; //#include //using namespace atcoder; using ll = long long int; using ull = unsigned long long int; using ld = long double; constexpr ll MAX = 2000000000000000000; constexpr ld PI = 3.14159265358979; constexpr ll MOD = 0;//2024948111; ld dotorad(ld K){return PI * K / 180.0;} ld radtodo(ld K){return K * 180.0 / PI;} mt19937 mt; void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());} int main(){ ll P,Q,X,Y; cin >> P >> Q >> X >> Y; while(Y % 10 == 0){ Y += Q; } string y = to_string(Y); string S = y; reverse(S.begin(),S.end()); ll f = stol(S) % P; while(1){ if(f == X){ cout << S << endl; { ll p = 0; for(ll i = 0;i < (ll)S.size();i++){ p = (p * 10) % P; p += S[i] - '0'; p %= P; } if(p != X % P) cout << "Error" << endl; } { ll p = 0; for(ll i = (ll)S.size() - 1;i >= 0;i--){ p = (p * 10) % Q; p += S[i] - '0'; p %= Q; } if(p != Y % Q) cout << "Error" << endl; } return 0; } S += "0"; f = (f * 10) % P; } }