#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int ksm(long long a,long long q,long long n)
{
long long ans=1,base=a;
while(q!=0)
{
if(q&1!=0)
ans=base*ans%n;
base=base*base%n;
q>>=1;
}
return ans%n;
}
int main()
{
freopen("CircleNOIP2013.in","r",stdin);
freopen("CircleNOIP2013.out","w",stdout);
long long n,m,k,x;//n是人数,m是走的数
//k是几轮,x是几号的位置;
cin>>n>>m>>k>>x;
long long lun=ksm(10,k,n);
int ans=(lun*m)%n;
ans+=x;
ans%=n;
cout<<ans;
}