#include <bits/stdc++.h>
using namespace std;
long long int ans;
int n, u, r;
int k[30], b[30], a[30], p[30];
void func(int v[], int y, int cnt) {
  if (cnt % 2 == 0) {
    long long int tmp = 0;
    for (int i = 0; i < n; i++) tmp += v[i] * k[i];
    ans = max(ans, tmp);
  }
  if (cnt == 0) {
    return;
  }
  int tmp[30];
  memcpy(tmp, a, sizeof(tmp));
  if (y == 1) {
    for (int i = 0; i < n; i++) tmp[i] = v[i] ^ b[i];
    func(tmp, 0, cnt - 1);
  }
  for (int i = 0; i < n; i++) tmp[i] = v[p[i]] + r;
  func(tmp, 1, cnt - 1);
}
int main() {
  std::ios_base::sync_with_stdio(0);
  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]--;
  ans = -1e18;
  func(a, 1, u);
  cout << ans << endl;
}
