#include <bits/stdc++.h>
using namespace std;
const int T = 40;
long long INF = -0x8000000000000000LL;
int a[T], b[T], k[T], p[T], n, u, r;
long long ans = INF;
inline void end() {
  long long tmp(0);
  for (int i = 1; i <= n; i++) tmp += a[i] * k[i];
  ans = ((tmp) > (ans) ? (tmp) : (ans));
}
inline void dfs(int now, int op) {
  if (now == u) {
    end();
    return;
  }
  if (((u - now) & 1) == 0) end();
  int sb[T];
  memcpy(sb + 1, a + 1, sizeof(int) * n);
  if (op) {
    for (int i = 1; i <= n; i++) a[i] ^= b[i];
    dfs(now + 1, 0);
    for (int i = 1; i <= n; i++) a[i] ^= b[i];
  }
  for (int i = 1; i <= n; i++) a[i] = sb[p[i]] + r;
  dfs(now + 1, 1);
  for (int i = 1; i <= n; i++) a[i] = sb[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]);
  dfs(0, 1);
  printf("%I64d\n", ans);
  return 0;
}
