#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 37;
const long long INF = 1LL << 61;
int n, u, r;
long long sum;
int a[MAX_N], b[MAX_N], k[MAX_N], p[MAX_N];
void dfs(int dep, bool f) {
  if ((u - dep) % 2 == 0) {
    long long s = 0;
    for (int i = 1; i <= n; ++i) {
      s += (long long)a[i] * k[i];
    }
    sum = max(sum, s);
  }
  if (dep == u) return;
  int t[MAX_N] = {0};
  for (int i = 1; i <= n; ++i) {
    t[i] = a[i];
  }
  if (!f) {
    for (int i = 1; i <= n; ++i) {
      a[i] = t[i] ^ b[i];
    }
    dfs(dep + 1, true);
  }
  for (int i = 1; i <= n; ++i) {
    a[i] = t[p[i]] + r;
  }
  dfs(dep + 1, false);
  for (int i = 1; i <= n; ++i) {
    a[i] = t[i];
  }
}
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);
  }
  sum = -INF;
  dfs(0, 0);
  printf("%I64d\n", sum);
  return 0;
}
