import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int M = sc.nextInt(); int N = sc.nextInt(); long mulX = sc.nextLong(); long addX = sc.nextLong(); long mulY = sc.nextLong(); long addY = sc.nextLong(); long MOD = sc.nextLong(); long[] z = new long[(int) MOD]; long[] x = new long[M]; long[] y = new long[M]; long[] a = new long[M]; long[] b = new long[M]; for (int i = 0; i < M; ++i) { x[i] = sc.nextLong(); } for (int i = 0; i < M; ++i) { y[i] = sc.nextLong(); z[(int) x[i]] += y[i]; } for (int i = 0; i < M; ++i) { a[i] = sc.nextLong(); } for (int i = 0; i < M; ++i) { b[i] = sc.nextLong(); } long curx = x[M - 1], cury = y[M - 1]; for (int i = M; i < N; ++i) { curx = (curx * mulX + addX) & (MOD - 1); cury = (cury * mulY + addY) & (MOD - 1); z[(int) curx] += cury; } boolean[] isPrime = new boolean[(int) MOD]; Arrays.fill(isPrime, true); isPrime[0] = false; isPrime[1] = false; for (int i = 2; i < isPrime.length; ++i) { if (isPrime[i]) for (int j = 2 * i; j < isPrime.length; j += i) isPrime[j] = false; } for (int i = 2; i < isPrime.length; ++i) { if (!isPrime[i]) continue; for (int j = (z.length - 1) / i; j >= 1; --j) { z[j] += z[j * i]; } } long ans = 0; for (int i = 0; i < M; ++i) { long v = z2(a[i], z) - z2(a[i] * b[i], z); System.out.println(v); ans ^= v; } long cura = a[M - 1] & (MOD - 1), curb = b[M - 1] & (MOD - 1); for (int i = M; i < N; ++i) { cura = ((((cura * mulX) & (MOD - 1)) + addX + MOD - 1) & (MOD - 1)) + 1; curb = ((((curb * mulY) & (MOD - 1)) + addY + MOD - 1) & (MOD - 1)) + 1; long v = z2(cura, z) - z2(cura * curb, z); ans ^= v; } System.out.println(ans); } long z2(long v, long[] z) { if (v >= z.length) return 0; else return z[(int) v]; } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }