#include<fstream>
using namespace std;
ifstream fin("CircleNOIP2013.in");
ofstream fout("CircleNOIP2013.out");
long long n,m,k,x;
long long qp(long long a,long long b)
{
if(b==0)
return 1;
long long t=qp(a,b/2);
if(b%2==0)
return ((t%n)*(t%n))%n;
return ((t%n)*(t%n)*(a%n))%n;
}
int main()
{
fin>>n>>m>>k>>x;
fout<<((x%n)+((qp(10,k)%n)*(m%n))%n)%n;
return 0;
}