#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
long long a[70];
int b[70];
int k[70];
int p[70];
int n, u, r;
long long ans;
void dfs(int m, long long *A, int q) {
  if (m % 2 == 0) {
    long long s = 0;
    for (int i = 1; i <= n; i++) s += A[i] * (long long)k[i];
    ans = max(ans, s);
    if (m == 0) return;
  }
  long long D[70];
  int ct = 0;
  if (q) {
    for (int i = 1; i <= n; i++) D[++ct] = A[i] ^ b[i];
    dfs(m - 1, D, 0);
  }
  ct = 0;
  for (int i = 1; i <= n; i++) D[++ct] = A[p[i]] + r;
  dfs(m - 1, D, 1);
}
int main() {
  ans = -0x7ffffffffffffff;
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 1; i <= n; i++) scanf("%I64d", &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(u, a, 1);
  printf("%I64d\n", ans);
  return 0;
}
