#include<cstdio>
long long n, m, k, x, mod;
long long ksm(long long a, long long b)
{
long long ret = 1, temp = a;
while(b)
{
if(b & 1) ret = (ret * temp) % mod;
temp = (temp * temp) % mod;
b >>= 1;
}
return ret;
}
int main()
{
freopen("CircleNOIP2013.in", "r", stdin);
freopen("CircleNOIP2013.out", "w", stdout);
scanf("%lld%lld%lld%lld", &n, &m, &k, &x);
mod = n;
long long power = ksm(10, k);
long long result = (x + ((power % mod) * (m % mod)) % mod) % mod;
printf("%lld", result);
fclose(stdin);
fclose(stdout);
return 0;
}