#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 31;
long long N, U, R;
long long A[MAXN], B[MAXN], K[MAXN], P[MAXN];
long long ans = -1e15;
void tryAns(vector<long long> &t) {
  long long cur = 0;
  for (long long i = 0; i < t.size(); i++) cur += t[i] * K[i];
  ans = max(ans, cur);
}
void calc(long long ops, vector<long long> vec) {
  vector<long long> t(vec);
  if (ops == U) {
    tryAns(vec);
    return;
  } else if (ops > U)
    return;
  else if (ops == U - 1) {
    for (long long i = 0; i < vec.size(); i++) vec[i] ^= B[i];
    tryAns(vec);
    vec = t;
  }
  if ((U - ops) % 2 == 0)
    tryAns(vec);
  else {
    for (long long i = 0; i < vec.size(); i++) vec[i] ^= B[i];
    tryAns(vec);
    vec = t;
  }
  for (long long i = 0; i < vec.size(); i++) vec[i] = t[P[i]] + R;
  calc(ops + 1, vec);
  vec = t;
  for (long long i = 0; i < vec.size(); i++) vec[i] ^= B[i];
  t = vector<long long>(begin(vec), end(vec));
  for (long long i = 0; i < vec.size(); i++) vec[i] = t[P[i]] + R;
  calc(ops + 2, vec);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> U >> R;
  for (long long i = 0; i < N; i++) cin >> A[i];
  for (long long i = 0; i < N; i++) cin >> B[i];
  for (long long i = 0; i < N; i++) cin >> K[i];
  for (long long i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }
  vector<long long> cVal(A, A + N);
  calc(0, cVal);
  cout << ans << endl;
}
