#include<fstream>
using namespace std;
ifstream fin("CircleNOIP2013.in");
ofstream fout("CircleNOIP2013.out");
long long n,m,k,x;
long long counter=1;
long long K=0;//
long long REAL=1;
int QuickPow(long long K,long long P)
{
if(P<=1) return K;
long long p=P/2;
long long temp;
temp=QuickPow(K,p);
temp=(temp%counter)*(temp%counter)%counter;
if(P%2==1)
return temp*K%counter;
else
return temp%counter;
}
int main()
{
fin>>n>>m>>k>>x;
int FLAG=x;
int i;
K+=m;
while(K>n-1)
K-=n;
while(K!=0)
{
K+=m;
while(K>n-1)
K-=n;
counter++;//有效轮数
}
/*for(i=1;i<=k;i++)
{
REAL*=10;
REAL%=counter;
}*/
REAL=QuickPow(10,k);
REAL=REAL%counter;
for(i=1;i<=REAL;i++)
{
FLAG+=m;
while(FLAG>n-1)
FLAG-=n;
}
fout<<FLAG<<endl;
return 0;
}