#include <bits/stdc++.h>
using namespace std;
long long n, u, r;
vector<long long> a, b, p, k;
long long ans = -1000000000000;
void func(long long turn, bool isxor) {
  long long i;
  if ((u - turn + 1) % 2 == 0) {
    long long sum = 0;
    for (i = 0; i < n; i++) sum += a[i] * k[i];
    ans = max(ans, sum);
  }
  if (turn > u) {
    return;
  }
  vector<long long> temp = a;
  if (!isxor) {
    for (i = 0; i < n; i++) a[i] = a[i] ^ b[i];
    func(turn + 1, true);
    a = temp;
  }
  for (i = 0; i < n; i++) {
    a[i] = temp[p[i] - 1] + r;
  }
  func(turn + 1, false);
  a = temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> u >> r;
  a.resize(n);
  b.resize(n);
  p.resize(n);
  k.resize(n);
  long long i;
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) cin >> b[i];
  for (i = 0; i < n; ++i) cin >> k[i];
  for (i = 0; i < n; ++i) cin >> p[i];
  func(1, false);
  cout << ans;
  return 0;
}
