#include <bits/stdc++.h>
using namespace std;
const int N = 31;
long long n, u, r, a[N], b[N], k[N], p[N], ans = -1e18, s;
void go(int t, int st = 0) {
  if ((u - st) % 2 == 0) {
    s = 0;
    for (int i = 0; i < n; i++) s += a[i] * k[i];
    ans = max(ans, s);
  }
  if (st == u) return;
  if (!t) {
    for (int i = 0; i < n; i++) a[i] = a[i] ^ b[i];
    go(1, st + 1);
    for (int i = 0; i < n; i++) a[i] = a[i] ^ b[i];
  } else {
    int tmp[N];
    for (int i = 0; i < n; i++) tmp[i] = a[i];
    for (int i = 0; i < n; i++) a[i] = tmp[p[i]] + r;
    go(1, st + 1), go(0, st + 1);
    for (int i = 0; i < n; i++) a[i] = tmp[i];
  }
}
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]--;
  go(0), go(1);
  cout << ans;
}
