#include <bits/stdc++.h>
using namespace std;
long long u, r;
long long n;
long long res;
long long a[50];
long long b[50];
long long k[50];
long long p[50];
long long c[50];
struct nujno {
  long long last;
  long long a[50];
  long long number;
};
stack<nujno> st;
void dfs() {
  while (!st.empty()) {
    nujno B = st.top();
    st.pop();
    long long result = 0;
    if (B.number % 2 == 0) {
      for (int i = 1; i <= n; ++i) {
        result += B.a[i] * k[i];
      }
      res = max(result, res);
    }
    if (B.number == 0) continue;
    if (B.last == 1) {
      for (int i = 1; i <= n; ++i) {
        c[i] = B.a[p[i]] + r;
      }
      for (int i = 1; i <= n; ++i) B.a[i] = c[i];
      B.number = B.number - 1;
      B.last = 2;
      st.push(B);
    } else {
      nujno C, D;
      for (int i = 1; i <= n; ++i) C.a[i] = B.a[i] ^ b[i];
      C.last = 1;
      C.number = B.number - 1;
      st.push(C);
      for (int i = 1; i <= n; ++i) c[i] = B.a[p[i]] + r;
      for (int i = 1; i <= n; ++i) D.a[i] = c[i];
      D.number = B.number - 1;
      D.last = 2;
      st.push(D);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> u >> r;
  res = (long long)(-1000000000000000000);
  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];
  nujno A;
  for (int i = 1; i <= n; ++i) A.a[i] = a[i];
  A.last = 2;
  A.number = u;
  st.push(A);
  dfs();
  cout << res;
  return 0;
}
