#include #include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; /*-------------------------------------------------*/ int main() { cin.tie(nullptr); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int m, n, mulX, addX, mulY, addY, mod; cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod; vector mp(mod, 0); vector X(m); REP(i, m) cin >> X[i]; long long x, y; REP(i, n) { if (i < m) { x = X[i]; cin >> y; } else { x = (x * mulX + addX) & (mod - 1); y = (y * mulY + addY) & (mod - 1); } mp[x] += y; } long long ans = 0; REP(i, m) cin >> X[i]; REP(i, n) { if (i < m) { x = X[i]; cin >> y; } else { x = ((x * mulX + addX + mod - 1) & (mod - 1)) + 1; y = ((y * mulY + addY + mod - 1) & (mod - 1)) + 1; } long long cnt = 0, mul = x * y; for (int i = x; i < mod; i += x) { if (i % mul != 0) cnt += mp[i]; } if (i < m) cout << cnt << '\n'; ans ^= cnt; } cout << ans << '\n'; return 0; }