#include <bits/stdc++.h>
const int MAXN = 30;
long long A[MAXN + 1][MAXN], B[MAXN], K[MAXN];
int P[MAXN];
long long buf[MAXN];
inline long long calc(int dep, int n) {
  int i;
  long long ret = 0;
  for (i = 0; i < n; ++i) ret += K[i] * A[dep][i];
  return ret;
}
long long BF(bool px, int dep, int n, int u, long long r) {
  if (dep == u) return calc(dep, n);
  long long ret, tmp;
  int i;
  for (i = 0; i < n; ++i) A[dep + 1][i] = A[dep][P[i]] + r;
  ret = BF(false, dep + 1, n, u, r);
  if (!px) {
    for (i = 0; i < n; ++i) A[dep + 1][i] = (A[dep][i] ^ B[i]);
    tmp = BF(true, dep + 1, n, u, r);
    if (ret < tmp) ret = tmp;
  }
  if (!((u - dep) & 1)) {
    tmp = calc(dep, n);
    if (ret < tmp) ret = tmp;
  }
  return ret;
}
int main() {
  int n, u, i;
  long long r;
  scanf("%d%d%I64d", &n, &u, &r);
  for (i = 0; i < n; ++i) scanf("%I64d", A[0] + i);
  for (i = 0; i < n; ++i) scanf("%I64d", B + i);
  for (i = 0; i < n; ++i) scanf("%I64d", K + i);
  for (i = 0; i < n; ++i) {
    scanf("%d", P + i);
    --P[i];
  }
  printf("%I64d\n", BF(false, 0, n, u, r));
  return 0;
}
