#include <bits/stdc++.h>
using namespace std;
int i, j, n, u, r;
long long an;
int b[40], k[40], p[40];
void bfs(int a[], int tp, int fg) {
  long long ans = 0;
  int c[40];
  for (i = 1; i <= n; i++) ans += a[i] * k[i];
  if ((u - tp) % 2 == 0) an = max(an, ans);
  if (tp == u) return;
  if (fg == 0) {
    for (i = 1; i <= n; i++) c[i] = a[i] ^ b[i];
    bfs(c, tp + 1, 1);
  }
  for (i = 1; i <= n; i++) c[i] = a[p[i]] + r;
  bfs(c, tp + 1, 0);
}
int a[40];
int main() {
  while (scanf("%d%d%d", &n, &u, &r) == 3) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (i = 1; i <= n; i++) scanf("%d", &b[i]);
    for (i = 1; i <= n; i++) scanf("%d", &k[i]);
    for (i = 1; i <= n; i++) scanf("%d", &p[i]);
    an = 1000000000;
    an = an * an * (-1);
    bfs(a, 0, 0);
    printf("%I64d\n", an);
  }
  return 0;
}
