#include #define endl '\n' using namespace std; const int MAXN=1e7+5; unsigned int n,a,b,c,d; unsigned int pow1[1050]; unsigned int pow2[20000000]; int main() { freopen("power.in","r",stdin); freopen("power.out","w",stdout); cin>>a>>b>>c>>d>>n; pow1[0]=1; for(int i=1;i<=1024;i++) { pow1[i]=pow1[i-1]*a; } pow2[0]=1; for(int i=1;i<=(1<<22);i++) { pow2[i]=pow2[i-1]*pow1[1024]; } unsigned int ans=0; for(int i=1;i<=n;i++) { b=b*c+d; unsigned int cur=pow2[b/1024]*pow1[b%1024]; ans=ans^cur; } cout<