#include <bits/stdc++.h>
using namespace std;
int a[40][40], b[40], p[40], k[40];
int n, u, t;
long long ans;
void dfs(int dep, int two) {
  long long tmp = 0;
  for (int i = 0; i < n; i++) tmp += (long long)a[dep][i] * k[i];
  if ((u - dep) % 2 == 0) ans = max(ans, tmp);
  if (dep == u) return;
  for (int i = 0; i < n; i++) a[dep + 1][i] = a[dep][p[i]] + t;
  dfs(dep + 1, 0);
  if (two == 1) return;
  for (int i = 0; i < n; i++) a[dep + 1][i] = (a[dep][i] ^ b[i]);
  dfs(dep + 1, 1);
}
int main() {
  while (scanf("%d%d%d", &n, &u, &t) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &a[0][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]--;
    ans = -(1ll << 60);
    dfs(0, 0);
    printf("%I64d\n", ans);
  }
  return 0;
}
