#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m, k;
int x[50], y[50], z[50], p[50];
long long go(int m, int j) {
  long long ans = -1e18;
  if (!(m & 1)) {
    ans = 0;
    for (int i = 0; i < n; i++) ans += (long long)x[i] * z[i];
    if (m == 0) return ans;
  }
  int X[50];
  for (int i = 0; i < n; i++) X[i] = x[i];
  if (!j) {
    for (int i = 0; i < n; i++) x[i] ^= y[i];
    ans = max(ans, go(m - 1, 1));
  }
  for (int i = 0; i < n; i++) x[i] = X[p[i] - 1] + k;
  ans = max(ans, go(m - 1, 0));
  for (int i = 0; i < n; i++) x[i] = X[i];
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int i = 0; i < n; i++) scanf("%d", &y[i]);
  for (int i = 0; i < n; i++) scanf("%d", &z[i]);
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  printf("%I64d\n", go(m, 0));
  return 0;
}
