#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(ll i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template bool chmax(T &x, const T &y) {return (x bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;}; constexpr ll MOD=1000000007; constexpr ll INF=2e18; int main(){ ll p, q, x, y; cin >> p >> q >> x >> y; string ans; ll n; for(ll i=(y==0?1:0);1;i++){ ans=to_string(q*i+y); reverse(ALL(ans)); n=0; REP(j,(int)ans.size()){ n=n*10%p; n=(n+ans[j]-'0')%p; } if(n!=0) break; } while(n!=x){ n=n*10%p; ans+='0'; } cout << ans << endl; return 0; }