#include <bits/stdc++.h>
using namespace std;
const int maxn = 42;
int a[maxn], b[maxn], k[maxn], p[maxn];
int n, u, r;
long long ANS = -1e18;
void go(int step, int x) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (a[i] * 1LL * k[i]);
  }
  if ((u - step) % 2 == 0) ANS = max(ANS, ans);
  if (step == u) return;
  int c[33];
  for (int i = 0; i < n; i++) c[i] = a[i];
  if (x == 0) {
    for (int i = 0; i < n; i++) {
      a[i] = a[i] ^ b[i];
    }
    go(step + 1, 1);
  }
  for (int i = 0; i < n; i++) {
    a[i] = c[p[i] - 1] + r;
  }
  go(step + 1, 0);
  return;
}
int main() {
  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]);
  go(0, 0);
  cout << ANS;
  return 0;
}
