#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
void Open() {}
int a[44][44], b[44], k[44], p[44];
int n, u, r;
long long ans;
void update(int dep) {
  long long res = 0;
  for (int i = 1; i <= n; i++) res += k[i] * a[dep + 1][i];
  ans = max(ans, res);
}
void dfs(int dep, bool prexor) {
  if (dep % 2 == 0) update(dep);
  if (dep == 0) return;
  if (!prexor) {
    for (int i = 1; i <= n; i++) a[dep][i] = a[dep + 1][i] ^ b[i];
    dfs(dep - 1, true);
  }
  for (int i = 1; i <= n; i++) a[dep][i] = a[dep + 1][p[i]] + r;
  dfs(dep - 1, false);
}
int main() {
  Open();
  while (~scanf("%d%d%d", &n, &u, &r)) {
    for (int i = 1; i <= n; i++) scanf("%d", a[u + 1] + 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);
    ans = -INF;
    dfs(u, 0);
    printf("%I64d\n", ans);
  }
  return 0;
}
