#include <bits/stdc++.h>
using namespace std;
int n, u, r;
long long a[33], b[33], k[33], p[33], ans = -0x7f7f7f7f;
long long calsum() {
  long long ret = 0;
  for (int i = 0; i < (int)(n); i++) ret += a[i] * k[i];
  return ret;
}
void dfs(int s, int last) {
  if (s >= u) {
    ans = max(ans, calsum());
    return;
  }
  if ((u - s) % 2 == 0) ans = max(ans, calsum());
  long long bak[33];
  memcpy(bak, a, sizeof(long long) * n);
  for (int i = 0; i < (int)(n); i++) a[i] = bak[p[i]] + r;
  dfs(s + 1, 1);
  if (last) {
    for (int i = 0; i < (int)(n); i++) a[i] = bak[i] ^ b[i];
    dfs(s + 1, 0);
  }
  memcpy(a, bak, sizeof(long long) * n);
}
int main(int argc, char *argv[]) {
  cin >> n >> u >> r;
  ans *= 0x7f7f7f7f;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(n); i++) cin >> b[i];
  for (int i = 0; i < (int)(n); i++) cin >> k[i];
  for (int i = 0; i < (int)(n); i++) {
    cin >> p[i];
    p[i]--;
  }
  dfs(0, 1);
  cout << ans << endl;
  return EXIT_SUCCESS;
}
