#include <bits/stdc++.h>
using namespace std;
const int N = 30;
struct complect {
  long long a[N];
  int ops;
  bool prev_was_xor;
};
int n, u, r;
long long a[N];
long long b[N];
long long k[N];
int p[N];
complect _seed(void) {
  complect R;
  for (int i = 0; i < n; i++) R.a[i] = a[i];
  R.ops = 0;
  R.prev_was_xor = false;
  return R;
}
complect type_1(const complect& A) {
  complect R;
  for (int i = 0; i < n; i++) R.a[i] = A.a[i] ^ b[i];
  R.ops = A.ops + 1;
  R.prev_was_xor = true;
  return R;
}
complect type_2(const complect& A) {
  complect R;
  for (int i = 0; i < n; i++) {
    R.a[i] = A.a[p[i]] + r;
  }
  R.ops = A.ops + 1;
  R.prev_was_xor = false;
  return R;
}
long long score(const complect& A) {
  long long result = 0;
  for (int i = 0; i < n; i++) result += A.a[i] * k[i];
  return result;
}
const long long INF = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
int main() {
  cin >> n >> u >> r;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> k[i];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  complect seed = _seed();
  stack<complect> all;
  all.push(seed);
  long long result = -INF;
  while (!all.empty()) {
    seed = all.top();
    all.pop();
    if (seed.ops < u) {
      all.push(type_2(seed));
      if (!seed.prev_was_xor) all.push(type_1(seed));
    }
    if (((u - seed.ops) & 1) == 0) result = max(result, score(seed));
  }
  cout << result;
  return 0;
}
