#include <bits/stdc++.h>
using namespace std;
const int N = 100;
inline int read() {
  char ch = getchar();
  int x = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  }
  return x * w;
}
inline long long readl() {
  char ch = getchar();
  long long x = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0', ch = getchar();
  }
  return x * w;
}
int n, u;
long long R, A[N], B[N], K[N], P[N], res;
inline void dfs(int now, bool p) {
  if (now == u + 1) return;
  if (!((u - now) & 1)) {
    long long t = 0;
    for (int i = 1; i <= n; ++i) t += (A[i] * K[i]);
    res = max(t, res);
  }
  if (!p) {
    for (int i = 1; i <= n; ++i) A[i] ^= B[i];
    dfs(now + 1, 1);
    for (int i = 1; i <= n; ++i) A[i] ^= B[i];
  }
  long long tmp[N];
  for (int i = 1; i <= n; ++i) tmp[i] = A[i];
  for (int i = 1; i <= n; ++i) A[i] = tmp[P[i]] + R;
  dfs(now + 1, 0);
  for (int i = 1; i <= n; ++i) A[i] = tmp[i];
}
int main() {
  while (scanf("%d%d%d", &n, &u, &R)) {
    for (int i = 1; i <= n; ++i) A[i] = readl();
    for (int i = 1; i <= n; ++i) B[i] = readl();
    for (int i = 1; i <= n; ++i) K[i] = readl();
    for (int i = 1; i <= n; ++i) P[i] = readl();
    res = -1e18;
    dfs(0, 0);
    printf("%I64d\n", res);
    return 0;
  }
}
