#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int MAXN = 32;
int k[MAXN];
int a[MAXN][MAXN];
int b[MAXN];
int p[MAXN];
int n, r;
long long doit(int u, bool xr) {
  long long s = -1ll << 60;
  if (u % 2 == 0) {
    s = 0;
    for (int i = 0; i < (n); ++i) s += a[u][i] * k[i];
  }
  if (u == 0) return s;
  if (xr) {
    for (int i = 0; i < (n); ++i) {
      a[u - 1][i] = a[u][i] ^ b[i];
    }
    s = max(s, doit(u - 1, false));
  }
  for (int i = 0; i < (n); ++i) {
    a[u - 1][i] = a[u][p[i]] + r;
  }
  s = max(s, doit(u - 1, true));
  return s;
}
int main() {
  int u;
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &a[u][i]);
  }
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &k[i]);
  }
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }
  long long res = doit(u, true);
  cout << res << endl;
  return 0;
}
