#include <bits/stdc++.h>
int N, U, R;
long long A[(32)];
int B[(32)];
int K[(32)];
int P[(32)];
long long sol;
int f1 = 1;
inline void eval() {
  long long res = 0;
  int i;
  for (i = 0; i < N; ++i) res += A[i] * K[i];
  if (sol < res || f1) {
    sol = res;
    f1 = 0;
  }
}
void gen(int id, int last) {
  if (!((id ^ U) & 1)) {
    eval();
  }
  if (id < U) {
    long long at[(32)];
    memcpy(at, A, sizeof(A));
    if (last == 1) {
      for (int i = 0; i < N; ++i) A[i] ^= B[i];
      gen(id + 1, 0);
      memcpy(A, at, sizeof(A));
    }
    for (int i = 0; i < N; ++i) A[i] = at[P[i]] + R;
    gen(id + 1, 1);
    memcpy(A, at, sizeof(A));
  }
}
int main() {
  int i;
  scanf("%d %d %d", &N, &U, &R);
  for (i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    A[i] = a;
  }
  for (i = 0; i < N; ++i) scanf("%d", B + i);
  for (i = 0; i < N; ++i) scanf("%d", K + i);
  for (i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    P[i] = a - 1;
  }
  gen(0, 1);
  printf("%I64d\n", sol);
  return 0;
}
