import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); int[] aArr = new int[n]; for (int i = 0; i < n; i++) { aArr[i] = sc.nextInt(); } long[] aCount = get(aArr); int[] bArr = new int[m]; for (int i = 0; i < m; i++) { bArr[i] = sc.nextInt(); } long[] bCount = get(bArr); long ans = 0; //System.out.println(Arrays.toString(aCount)); for (int i = 0; i < 1024; i++) { ans += aCount[i] * bCount[i ^ k]; } System.out.println(ans); } static long[] get(int[] arr) { long[] counts = new long[1024]; counts[0]++; int base = 0; for (int x : arr) { base ^= x; counts[base]++; } long[] ans = new long[1024]; for (int i = 0; i < 1024; i++) { for (int j = i + 1; j < 1024; j++) { ans[i ^ j] += counts[i] * counts[j]; } } for (long x : counts) { ans[0] += x * (x - 1) / 2; } return ans; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }