#include<iostream>
#include<fstream>
using namespace std;
ifstream fi("CircleNOIP2013.in");
ofstream fo("CircleNOIP2013.out");
#define cin fi
#define cout fo
const long long MAXN = 1000001;
long long n, m, k, x;
inline long long qpow(long long, long long);
main()
{
ios::sync_with_stdio(0);
cin >> n >> m >> k >> x;
long long l = qpow(10, k), ans;
l *= m;
l %= n;
ans = (x + l) % n;
cout << ans;
// cin >> n;
}
inline long long qpow(long long a, long long p)
{
long long ret = 1;
while(p > 0){
if(p & 1)
ret = (ret * a) % n;
a = (a * a) % n;
p >>= 1;
}
return ret % n;
}