#include <bits/stdc++.h>
using namespace std;
const int N = 33;
long long n, u, r, a[N][N], b[N], k[N], p[N], ans;
void dfs(int i, bool lastXor) {
  if ((u - i) % 2 == 0) {
    long long s = 0;
    for (int j = 0; j < n; j++) s += (long long)a[i][j] * k[j];
    ans = max(ans, s);
  }
  if (i < u) {
    for (int j = 0; j < n; j++) a[i + 1][j] = a[i][p[j]] + r;
    dfs(i + 1, false);
    if (!lastXor) {
      for (int j = 0; j < n; j++) a[i + 1][j] = a[i][j] ^ b[j];
      dfs(i + 1, true);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> u >> r;
  for (int i = 0; i < n; i++) cin >> a[0][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]--;
  ans = -(1LL << 62);
  dfs(0, false);
  cout << ans << endl;
  return 0;
}
