// #include // using namespace atcoder; #include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define popcnt(x) __builtin_popcount(x) using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vll = vector; using vvi = vector>; using vvll = vector>; const int inf = 1e9; const ll lim = 1e18; int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; int main() { cin.tie(0); ios::sync_with_stdio(false); int m, n, mulx, addx, muly, addy, mod; cin >> m >> n >> mulx >> addx >> muly >> addy >> mod; vi xx(m), yy(m), aa(m), bb(m); rep(i, m) cin >> xx[i]; rep(i, m) cin >> yy[i]; rep(i, m) cin >> aa[i]; rep(i, m) cin >> bb[i]; int mask = mod - 1; vi zz(mod); rep(i, m) zz[xx[i]] += yy[i]; int x = xx[m - 1], y = yy[m - 1]; rep(i, n - m) { x = (x * mulx + addx) & mask; y = (y * muly + addy) & mask; zz[x] += y; } rep(i, mod) { if (i == 0) continue; for (int j = i + i; j < mod; j += i) zz[i] += zz[j]; } int s = 0; rep(i, m) { int ans; if (aa[i] * bb[i] < mod) ans = zz[aa[i]] - zz[aa[i] * bb[i]]; else ans = zz[aa[i]]; s ^= ans; cout << ans << endl; } int a = aa[m - 1], b = bb[m - 1]; rep(_, n - m) { a = ((a * mulx + addx + mod - 1) & mask) + 1; b = ((b * muly + addy + mod - 1) & mask) + 1; if (a * b < mod) s ^= zz[a] - zz[a * b]; else s ^= zz[a]; } cout << s << endl; return 0; }