#include <bits/stdc++.h>
int a[40][40], b[40], k[40], p[40];
int n, u, r;
using namespace std;
long long g_ans;
void dfs(int dep, int pre) {
  int i;
  long long itmp = 0;
  if (!((u - dep) & 0x1)) {
    for (i = 1; i <= n; i++) itmp += a[dep][i] * (long long)k[i];
    g_ans = (((g_ans) > (itmp)) ? (g_ans) : (itmp));
  }
  if (dep == u) return;
  for (i = 1; i <= n; i++) a[dep + 1][i] = a[dep][p[i]] + r;
  dfs(dep + 1, 0);
  if (pre == 1) return;
  for (i = 1; i <= n; i++) a[dep + 1][i] = a[dep][i] ^ b[i];
  dfs(dep + 1, 1);
}
int main() {
  int i, j;
  scanf("%d %d %d", &n, &u, &r);
  for (i = 1; i <= n; i++) scanf("%d", a[0] + 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);
  g_ans = -100000000000LL;
  dfs(0, 0);
  cout << g_ans << endl;
}
