#include <bits/stdc++.h>
using namespace std;
long long A[50];
long long B[50];
long long K[50];
int P[50];
int Q[50];
long long cmemo[50][2];
long long count(int u, int i) {
  long long ans = cmemo[u][i];
  if (ans != -1) return ans;
  if (u == 0) return ans = 1;
  ans = 0;
  ans += count(u - 1, 0);
  if (i == 0) ans += count(u - 1, 1);
  return ans;
}
int N, U, R;
long long temp[50];
long long temp2[50];
void apply(int bit) {
  for (int i = (1); i <= (N); i++) {
    if (bit)
      temp2[i] = temp[i] ^ B[i];
    else
      temp2[i] = temp[P[i]] + R;
  }
  for (int i = (1); i <= (N); i++) temp[i] = temp2[i];
}
void unapply(int bit) {
  for (int i = (1); i <= (N); i++) {
    if (bit)
      temp2[i] = temp[i] ^ B[i];
    else
      temp2[i] = temp[Q[i]] - R;
  }
  for (int i = (1); i <= (N); i++) temp[i] = temp2[i];
}
long long mycount;
long long btrack(int lastbit, int lgt) {
  long long ans = 0;
  for (int i = (1); i <= (N); i++) ans += K[i] * temp[i];
  if (U == lgt) return ans;
  if ((U - lgt) % 2) ans = -1000000000000000000ll;
  apply(0);
  ans = max(ans, btrack(0, lgt + 1));
  unapply(0);
  if (lastbit == 0) {
    apply(1);
    ans = max(ans, btrack(1, lgt + 1));
    unapply(1);
  }
  return ans;
}
int main() {
  memset(cmemo, -1, sizeof(cmemo));
  cin >> N >> U >> R;
  for (int i = (1); i <= (N); i++) cin >> A[i];
  for (int i = (1); i <= (N); i++) cin >> B[i];
  for (int i = (1); i <= (N); i++) cin >> K[i];
  for (int i = (1); i <= (N); i++) cin >> P[i];
  for (int i = (1); i <= (N); i++) Q[P[i]] = i;
  mycount = 0;
  for (int i = (1); i <= (N); i++) temp[i] = A[i];
  long long ans = btrack(0, 0);
  cout << ans << endl;
}
