#include <bits/stdc++.h>
int n, u, r;
int a[31][31], b[31], k[31], p[31];
long long ans = -10000000000000LL;
void op1(int x) {
  for (int i = 1; i <= n; i++) a[x][i] = a[x - 1][i] ^ b[i];
}
void op2(int x) {
  for (int i = 1; i <= n; i++) a[x][i] = a[x - 1][p[i]] + r;
}
void checkSum(int x) {
  long long temp = 0;
  for (int i = 1; i <= n; i++) temp += (long long)a[x][i] * k[i];
  if (ans < temp) ans = temp;
}
void run(int x, bool isOp1) {
  long long temp;
  if (!isOp1) {
    op1(x);
    if (((u - x) & 1) == 0) checkSum(x);
    if (x < u) run(x + 1, true);
  }
  op2(x);
  if (((u - x) & 1) == 0) checkSum(x);
  if (x < u) run(x + 1, false);
}
int main() {
  scanf("%d %d %d", &n, &u, &r);
  for (int i = 1; i <= n; i++) scanf("%d", &a[0][i]);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  for (int i = 1; i <= n; i++) scanf("%d", k + i);
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  if ((u & 1) == 0) checkSum(0);
  run(1, false);
  printf("%I64d\n", ans);
  return 0;
}
