#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef string::const_iterator State; #define Ma_PI 3.141592653589793 #define eps 1e-5 #define LONG_INF 1000000000000000000LL #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007LL #define GYAKU 500000004LL #define MOD 998244353LL #define seg_size 262144*4 #define REP(a,b) for(long long a = 0;a < b;++a) long long x[2001]; long long y[2001]; long long a[2001]; long long b[2001]; long long z[(1 << 23) + 1]; long long cnt[(1 << 21) + 1]; bool visited[(1 << 21) + 1]; long long mod; long long calc_ans(long long now) { if (now < (1 << 20) && visited[now] == 1) { return cnt[now]; } long long ans = 0; for (long long q = 1; now * q < mod; ++q) { ans += z[now * q]; } if (now < 1 << 20) { visited[now] = 1; cnt[now] = ans; } return ans; } int main(){ #define int long long long long m, n, mulX, addX, mulY, addY; cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod; REP(i, m) { cin >> x[i]; } REP(i, m) { cin >> y[i]; } REP(i, m) { cin >> a[i]; } REP(i, m) { cin >> b[i]; } long long now_x = x[m - 1]; long long now_y = y[m - 1]; long long now_a = a[m - 1]; long long now_b = b[m - 1]; for (int i = 0; i < n; ++i) { if (i < m) { now_x = x[i]; now_y = y[i]; now_a = a[i]; now_b = b[i]; } else { now_x = (now_x * mulX + addX) & (mod - 1); now_y = (now_y * mulY + addY) & (mod - 1); now_a = ((now_a * mulX + addX + mod - 1) & (mod - 1)) + 1; now_b = ((now_b * mulY + addY + mod - 1) & (mod - 1)) + 1; } z[now_x] += now_y; } long long final_go = 0; for (int i = 0; i < m; ++i) { now_x = x[i]; now_y = y[i]; now_a = a[i]; now_b = b[i]; long long hoge = calc_ans(now_a) - calc_ans(now_a * now_b); cout << hoge << endl; final_go ^= hoge; } for (int i = m; i < n; ++i) { now_x = (now_x * mulX + addX) & (mod - 1); now_y = (now_y * mulY + addY) & (mod - 1); now_a = ((now_a * mulX + addX + mod - 1) & (mod - 1)) + 1; now_b = ((now_b * mulY + addY + mod - 1) & (mod - 1)) + 1; long long hoge = calc_ans(now_a) - calc_ans(now_a * now_b); final_go ^= hoge; } cout << final_go << endl; }