#include using namespace std; //const long long mod=4294967296; string mod="4294967296"; const int MAXN=1e7+10; string bi[MAXN]; string ai[MAXN]; void del0(string &a) { int br=0; while(a[br]=='0')br++; a.erase(0,br); } bool srv(string &a, string &b) { del0(a); del0(b); if(a.size()!=b.size())return a.size() > b.size(); return a>=b; } string sub(string a,string b) { string res=""; int pre=0; while(a.size()=0;i--) { int tmp=(a[i]-'0')+(b[i]-'0')+pre; if(tmp>=10) { tmp-=10; pre=1; } else pre=0; res=char(tmp+'0')+res; } if(pre)res="1"+res; return res; } string izv(string a,string b) { int zaem=0; string res=""; while(a.size()=0;i--) { int tmp=(a[i]-b[i])-zaem; if(tmp<0) { zaem=1; tmp+=10; } else zaem=0; res=char(tmp+'0')+res; } del0(res); return res; } string umn(string a,string b) { string res; int pre=0,i,j; res.resize(a.size()+b.size(),'0'); for(i=a.size()-1;i>=0;i--) { for(j=b.size()-1;j>=0;j--) { int tmp=(a[i]-'0')*(b[j]-'0')+(res[i+j+1]-'0')+pre; pre=tmp/10; tmp%=10; res[i+j+1]=tmp+'0'; } res[i+j+1]=pre+'0'; pre=0; } res=char(pre+'0')+res; del0(res); return res; } pair del(string a,string b) { string res=""; int L1=a.size(); int L2=b.size(); string part=a.substr(0,L2-1); for(int i=L2-1;i>a>>b>>c>>d>>n; string sc=""; string sd=""; string sa=""; while(b>0) { bi[0]+=char(b%10+'0'); b/=10; } reverse(bi[0].begin(),bi[0].end()); while(c>0) { sc+=char(c%10+'0'); c/=10; } reverse(sc.begin(),sc.end()); while(d>0) { sd+=char(d%10+'0'); d/=10; } reverse(sd.begin(),sd.end()); while(a>0) { sa+=char(a%10+'0'); a/=10; } reverse(sa.begin(),sa.end()); for(int i=1; i<=n; i++) { bi[i]=del((sub(del(umn(bi[i-1],sc),mod).second,sd)),mod).second; //bi[i]=umn(bi[i-1],sc); //cout<