#include <bits/stdc++.h>
using namespace std;
const int N = 30;
int a[N], b[N], k[N], p[N], tmp[N], op[N];
int n, u, r;
long long go(int u, bool can_f) {
  long long ans = (long long)-1e18;
  if (u % 2 == 0) {
    ans = 0;
    for (int i = 0; i < ((int)(n)); ++i) ans += a[i] * k[i];
  }
  if (u >= 1) {
    if (can_f) {
      for (int i = 0; i < ((int)(n)); ++i) a[i] ^= b[i];
      ans = max(ans, go(u - 1, false));
      for (int i = 0; i < ((int)(n)); ++i) a[i] ^= b[i];
    }
    for (int i = 0; i < ((int)(n)); ++i) tmp[i] = a[i];
    for (int i = 0; i < ((int)(n)); ++i) a[i] = tmp[p[i]] + r;
    ans = max(ans, go(u - 1, true));
    for (int i = 0; i < ((int)(n)); ++i) tmp[i] = a[i];
    for (int i = 0; i < ((int)(n)); ++i) a[i] = tmp[op[i]] - r;
  }
  return ans;
}
int main() {
  srand(time(NULL));
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 0; i < ((int)(n)); ++i) scanf("%d", &a[i]);
  for (int i = 0; i < ((int)(n)); ++i) scanf("%d", &b[i]);
  for (int i = 0; i < ((int)(n)); ++i) scanf("%d", &k[i]);
  for (int i = 0; i < ((int)(n)); ++i) {
    scanf("%d", &p[i]);
    p[i]--;
    op[p[i]] = i;
  }
  printf("%I64d\n", go(u, true));
  return 0;
}
