#include <bits/stdc++.h>
using namespace std;
long long int res = LLONG_MIN;
int n, u, r;
int A[50][50];
int B[50];
long long int K[50];
int P[50];
long long int calc(int d) {
  long long int res = 0;
  for (int i = 1; i <= n; i++) res += A[d][i] * K[i];
  return (res);
}
void doMagic(int d = 0, bool lol = false) {
  if (d == u) {
    res = max(res, calc(u));
    return;
  }
  if ((u - d) & 1) {
  } else {
    res = max(res, calc(d));
  }
  for (int i = 1; i <= n; i++) A[d + 1][i] = (A[d][P[i]] + r);
  doMagic(d + 1, false);
  if (lol) return;
  for (int i = 1; i <= n; i++) A[d + 1][i] = (A[d][i] ^ B[i]);
  doMagic(d + 1, true);
}
int main() {
  cin >> n >> u >> r;
  for (int i = 1; i <= n; i++) cin >> A[0][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];
  doMagic();
  cout << res;
  return (0);
}
