#include <bits/stdc++.h>
using namespace std;
long long n, u, r;
long long a[40], b[40], k[40], p[40];
long long maxx = (long long)1 << 63;
long long eval() {
  long long val = 0;
  for (int i = 0; i < n; i++) {
    val += a[i] * k[i];
  }
  return val;
}
void gen(int now, int last) {
  if (now % 2 == u % 2) maxx = max(maxx, eval());
  if (now < u) {
    long long temp[40];
    memcpy(temp, a, sizeof(a));
    if (last == 1) {
      for (int i = 0; i < n; i++) {
        a[i] = temp[i] ^ b[i];
      }
      gen(now + 1, 0);
    }
    for (int i = 0; i < n; i++) {
      a[i] = temp[p[i]] + r;
    }
    gen(now + 1, 1);
  }
}
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]--;
  }
  gen(0, 1);
  cout << maxx << endl;
  return 0;
}
