# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, k, x;
ll mpow(ll a, ll p) {
ll ans = 1;
for(; p; p >>= 1) {
if(p & 1) ans = (ans * a) % n;
a = (a * a) % n;
}
return ans % n;
}
int main() {
freopen("CircleNOIP2013.in","r",stdin);
freopen("CircleNOIP2013.out","w",stdout);
cin >> n >> m >> k >> x;
ll tmp = mpow(10, k) * m;
tmp %= n;
ll ans = (tmp + x) % n;
cout << ans << endl;
return 0;
}