#include <bits/stdc++.h>
#pragma warning(disable : 4786)
using namespace std;
int a[32][30];
int b[30], k[30], p[30];
int n, u, r;
long long maxn = -1000000000000000LL;
long long count(int pos) {
  long long s = 0;
  for (int i = 0; i < n; ++i) s += a[pos][i] * k[i];
  return s;
}
void Go(int pos) {
  if ((u - pos) % 2 == 0) maxn = max(maxn, count(pos));
  if (pos < u) {
    for (int i = 0; i < n; ++i) a[pos + 1][i] = a[pos][p[i]] + r;
    Go(pos + 1);
    for (int i = 0; i < n; ++i) a[pos + 1][i] = a[pos][i] ^ b[i];
    if ((u - pos - 1) % 2 == 0) maxn = max(maxn, count(pos + 1));
    if (pos + 1 < u) {
      for (int i = 0; i < n; ++i) a[pos + 2][i] = a[pos + 1][p[i]] + r;
      Go(pos + 2);
    }
  }
}
int main() {
  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];
  }
  Go(0);
  cout << maxn << endl;
  return 0;
}
