#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
int n, r;
int a[50], b[50], k[50], p[50];
long long ans;
void go(int u, int prev) {
  if (!(u & 1)) {
    long long aux = 0;
    for (int i = (0); i < (n); ++i) aux += a[i] * (long long)k[i];
    ans = max(ans, aux);
  }
  if (u == 0) return;
  int aux[40];
  for (int i = (0); i < (n); ++i) {
    aux[i] = a[i];
    a[i] ^= b[i];
  }
  if (!prev) go(u - 1, 1);
  for (int i = (0); i < (n); ++i) {
    a[i] = aux[p[i]] + r;
  }
  go(u - 1, 0);
  for (int i = (0); i < (n); ++i) a[i] = aux[i];
}
int main() {
  int u;
  scanf("%d %d %d", &n, &u, &r);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &b[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &k[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &p[i]), --p[i];
  ans = -10000000000000;
  go(u, 0);
  cout << ans << endl;
  return 0;
}
