#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[40], b[40], k[40], p[40], tmp[40];
long long ans = -10000000000000000ll;
long long cal() {
  long long ret = 0;
  for (int i = 0; i < n; i++) ret += 1ll * a[i] * k[i];
  return ret;
}
void dfs(int d, int t) {
  if (d == u) {
    ans = max(ans, cal());
    return;
  }
  if ((u - d) % 2 == 0) ans = max(ans, cal());
  if (t) {
    for (int i = 0; i < n; i++) tmp[i] = a[p[i]] + r;
    memcpy(a, tmp, sizeof(tmp));
    dfs(d + 1, t);
    dfs(d + 1, 0);
    for (int i = 0; i < n; i++) tmp[p[i]] = a[i] - r;
    memcpy(a, tmp, sizeof(tmp));
  } else {
    for (int i = 0; i < n; i++) a[i] ^= b[i];
    dfs(d + 1, 1);
    for (int i = 0; i < n; i++) a[i] ^= b[i];
  }
}
int main() {
  while (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];
    dfs(0, 0);
    dfs(0, 1);
    cout << ans << endl;
  }
  return 0;
}
