#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #define ll long long #define eps 1e-8 #define all(x) x.begin(), x.end() #define Cout cout << fixed << setprecision(6) using namespace std; unsigned int F[100000] = { 0 }; unsigned int G[100000] = { 0 }; unsigned int H[100000] = { 0 }; unsigned int cur = 0; unsigned int a, b; vector > > g(100006); void generate_masks(int n) { for (int i = 0; i < (1 << n); ++i) { for (int i1 = 0; i1 <= i; ++i1) { for (int i2 = 0; i2 <= i; ++i2) { if ((i1 | i2) == i) { g[i].push_back(make_pair(i1, i2)); } } } } } unsigned int nextRand16() { cur = cur * a + b; return cur / (1 << 16); } int main(){ #ifndef _DEBUG freopen("convolution.in", "r", stdin); freopen("convolution.out", "w", stdout); #endif #ifdef _DEBUG freopen("input.txt", "r", stdin); #endif unsigned int n, t; cin >> n >> t >> a >> b; generate_masks(n); while (t--){ for (int i = 0; i < (1 << n); ++i) H[i] = 0; for (int i = 0; i < (1 << n); ++i) F[i] = nextRand16(); for (int i = 0; i < (1 << n); ++i) G[i] = nextRand16(); for (int i = 0; i < (1 << n); ++i) { unsigned int k = 0; for (int q = 0; q < g[i].size(); ++q) { H[i] = H[i] + F[g[i][q].first] * G[g[i][q].second]; /*overflows here*/ } } ll ans = 0; for (int i = 0; i < (1 << n); ++i) { ans += H[i] * (i + 1); } ans %= (1ll << 32); cout << ans << endl; } return 0; }