#include <bits/stdc++.h>
using namespace std;
const int NMAX = 55;
int N, U, R, A[NMAX], B[NMAX], K[NMAX], P[NMAX];
long long Ans = -(1LL << 62);
void Back(int Ops, int Last) {
  if ((U - Ops) % 2 == 0) {
    long long Now = 0;
    for (int i = 1; i <= N; ++i) Now += 1LL * A[i] * K[i];
    Ans = max(Ans, Now);
  }
  if (Ops >= U) return;
  int Aux[NMAX], NA[NMAX];
  if (Last != 0) {
    for (int i = 1; i <= N; ++i) Aux[i] = A[i];
    for (int i = 1; i <= N; ++i) A[i] ^= B[i];
    Back(Ops + 1, 0);
    for (int i = 1; i <= N; ++i) A[i] = Aux[i];
  }
  for (int i = 1; i <= N; ++i) Aux[i] = A[i];
  for (int i = 1; i <= N; ++i) NA[i] = A[P[i]] + R;
  for (int i = 1; i <= N; ++i) A[i] = NA[i];
  Back(Ops + 1, 1);
  for (int i = 1; i <= N; ++i) A[i] = Aux[i];
}
int main() {
  scanf("%i %i %i", &N, &U, &R);
  for (int i = 1; i <= N; ++i) scanf("%i", &A[i]);
  for (int i = 1; i <= N; ++i) scanf("%i", &B[i]);
  for (int i = 1; i <= N; ++i) scanf("%i", &K[i]);
  for (int i = 1; i <= N; ++i) scanf("%i", &P[i]);
  Back(0, -1);
  printf("%I64d\n", Ans);
}
