#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int m, n, mx, ax, my, ay, mod; cin >> m >> n >> mx >> ax >> my >> ay >> mod; vectorx(m), y(m), a(m), b(m); rep(i, m)cin >> x[i]; rep(i, m)cin >> y[i]; rep(i, m)cin >> a[i]; rep(i, m)cin >> b[i]; vectorz(1 << 24); long long lx = x[m - 1]; long long ly = y[m - 1]; rep(i, n) { if (i < m) { z[x[i]] += y[i]; } else { lx = (lx * mx + ax) % mod; ly = (ly * my + ay) % mod; z[lx] += ly; } } rep2(i, 1, z.size()) { for (int j = i * 2; j < (1 << 24); j += i) { z[i] += z[j]; } } long long ans = 0; long long la = a[m - 1]; long long lb = b[m - 1]; rep(i, n) { long long val = 0; if (i < m) { if (a[i] < mod) val += z[a[i]]; if (a[i] * b[i] < mod)val -= z[a[i] * b[i]]; cout << val << endl; } else { la = (la * mx + ax + mod - 1) % mod + 1; lb = (lb * my + ay + mod - 1) % mod + 1; if (la < mod)val += z[la]; if (la * lb < mod)val -= z[la *lb]; } ans ^= val; } cout << ans << endl; return 0; }