#define P 998244353 int n , m , T; int range; unsignedint seed; inlineunsignedintrandint() { seed^=seed<<13; seed^=seed>>7; seed^=seed<<5; return seed%range+1; }
int f[MAXN];
intPow( int x , int a ){ int ret = 1; while( a ) { if( a & 1 ) ret = ret * 1ll * x % P; x = x * 1ll * x % P , a >>= 1; } return ret; }
int N[MAXN] , M[MAXN] , preM[MAXN];
voidsolve(){ cin >> T >> seed >> range; int ans = 0; rep( i , 1 , T ) { N[i] = randint() , M[i] = randint(); if( N[i] < M[i] ) swap( N[i] , M[i] ); } preM[0] = 1; rep( i , 1 , T ) preM[i] = preM[i - 1] * 1ll * ( M[i] + 1 ) % P; int mul = 1 , iv = Pow( preM[T] , P - 2 ); per( i , T , 1 ) { ans ^= ( N[i] + P - ( N[i] - M[i] ) * 1ll * iv % P * preM[i - 1] % P ) % P; iv = iv * 1ll * ( M[i] + 1 ) % P; } cout << ans << endl; }