#include <bits/stdc++.h>
using namespace std;
const int N = 33;
int a[N], b[N], k[N], p[N];
int n, u, r;
long long res = -(1LL << 60);
void calc(int* a, int j, int prv) {
  if ((u - j) % 2 == 0) {
    long long q = 0;
    for (int i = 0; i < n; ++i) q += a[i] * k[i];
    if (res < q) res = q;
  }
  if (j == u) return;
  if (prv == 1) {
    int na[N];
    for (int i = 0; i < n; ++i) na[i] = a[i] ^ b[i];
    calc(na, j + 1, 0);
  }
  int na[N];
  for (int i = 0; i < n; ++i) na[i] = a[p[i]] + r;
  calc(na, j + 1, 1);
}
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);
    --p[i];
  }
  calc(a, 0, 1);
  printf("%lld\n", res);
  return 0;
}
