#include using namespace std; using ll=long long; using ull=unsigned long long; using pii=pair; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(),a.end() #define rrng(a) a.end(),a.begin() #define rep(i,N) for(int i=0;i>a>>b>>x>>N; ll t=0,ao=0; ll tb=0,tw=0,aob=0,aow=0; for(ll i=0;i<2*N;i++){ x=(a*x+b)%6; ll X=x%6+1; if(i%2==0){ t+=X; if(t%2==0)tb++; else tw++; } else{ ao+=X; if(ao%2==0)aob++; else aow++; } } cout<