#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[50], b[50], p[50], k[50];
long long sol = 0;
bool first = true;
int rec(int t, bool ch) {
  if ((u - t) % 2 == 0) {
    long long tt = 0;
    for (int i = 1; i <= n; i++) {
      tt = tt + (((long long)a[i]) * ((long long)k[i]));
    }
    if (first) {
      sol = tt;
      first = false;
    } else
      sol = max(sol, tt);
  }
  if (t < u) {
    int tmp[50];
    for (int i = 1; i <= n; i++) tmp[i] = a[i];
    if (ch) {
      for (int i = 1; i <= n; i++) a[i] = tmp[i] ^ b[i];
      rec(t + 1, false);
    }
    for (int i = 1; i <= n; i++) a[i] = tmp[p[i]] + r;
    rec(t + 1, true);
    for (int i = 1; i <= n; i++) a[i] = tmp[i];
  }
  return 0;
}
int main() {
  scanf("%d %d %d", &n, &u, &r);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &k[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  rec(0, true);
  printf("%I64d\n", sol);
  return 0;
}
