#include <bits/stdc++.h>
using namespace std;
int b[33], c[33], p[33];
int n, u, r;
long long sum, ans;
void dfs(int now, int a[], int id) {
  int d[33], i;
  if (now == u + 1 || (u - now + 1) % 2 == 0) {
    sum = 0;
    for (i = 1; i <= n; i++) {
      sum += (long long)a[i] * c[i];
    }
    ans = max(ans, sum);
    if (now == u + 1) return;
  }
  for (i = 1; i <= n; i++) {
    d[i] = a[p[i]] + r;
  }
  dfs(now + 1, d, 2);
  if (id == 2) {
    for (i = 1; i <= n; i++) {
      d[i] = a[i] ^ b[i];
    }
    dfs(now + 1, d, 1);
  }
}
int main() {
  int i, j;
  int a[33];
  while (scanf("%d%d%d", &n, &u, &r) != EOF) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    for (i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
    }
    for (i = 1; i <= n; i++) {
      scanf("%d", &c[i]);
    }
    for (i = 1; i <= n; i++) {
      scanf("%d", &p[i]);
    }
    ans = -1;
    for (i = 1; i <= 16; i++) {
      ans *= 10;
    }
    dfs(1, a, 2);
    cout << ans << endl;
  }
  return 0;
}
