#include <bits/stdc++.h>
using namespace std;
long long n, u, r;
long long ans = -1e18;
long long a[35], b[35], k[35], p[35];
void check_max(long long buf[]) {
  long long max = 0;
  for (int i = 1; i <= n; i++) max += buf[i] * k[i];
  ans = ans > max ? ans : max;
}
void dfs(long long deep, long long buf[]) {
  if (deep == u) {
    check_max(buf);
    return;
  }
  long long t1[35], t2[35];
  for (int i = 1; i <= n; i++) t1[i] = buf[i] ^ b[i];
  if ((u - deep) % 2)
    check_max(t1);
  else
    check_max(buf);
  for (int i = 1; i <= n; i++) t2[i] = buf[p[i]] + r;
  dfs(deep + 1, t2);
  if (deep < u - 1) {
    for (int i = 1; i <= n; i++) t2[i] = t1[p[i]] + r;
    dfs(deep + 2, t2);
  }
}
int main() {
  int i;
  cin >> n >> u >> r;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  for (i = 1; i <= n; i++) cin >> k[i];
  for (i = 1; i <= n; i++) cin >> p[i];
  dfs(0, a);
  cout << ans << endl;
  return 0;
}
