#include <bits/stdc++.h>
using namespace std;
inline int inn() {
  int x, ch;
  while ((ch = getchar()) < '0' || ch > '9')
    ;
  x = ch ^ '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ '0');
  return x;
}
int n, m, r, p[50], k[50];
long long ans, a[50], b[50], sav[50][50], tmp[50];
inline int cmp(long long *a, long long *b) {
  for (int i = 1; i <= n; i++) a[i] = b[i];
  return 0;
}
inline int upd1(long long *a) {
  for (int i = 1; i <= n; i++) a[i] ^= b[i];
  return 0;
}
inline int upd2(long long *a) {
  for (int i = 1; i <= n; i++) tmp[i] = a[p[i]] + r;
  for (int i = 1; i <= n; i++) a[i] = tmp[i];
  return 0;
}
inline long long calc(long long *a) {
  long long x = 0;
  for (int i = 1; i <= n; i++) x += k[i] * a[i];
  return x;
}
long long dfs(int x, int las) {
  if ((m - x + 1) & 1)
    cmp(sav[x], a), upd1(a), ans = max(ans, calc(a)), cmp(a, sav[x]);
  else
    ans = max(ans, calc(a));
  if (x == m + 1) return ans = max(ans, calc(a));
  cmp(sav[x], a), upd2(a), dfs(x + 1, 2), cmp(a, sav[x]);
  if (las == 1) return 0;
  cmp(sav[x], a), upd1(a), dfs(x + 1, 1), cmp(a, sav[x]);
  return 0;
}
int main() {
  n = inn(), m = inn(), r = inn(), ans = LLONG_MIN;
  for (int i = 1; i <= n; i++) a[i] = inn();
  for (int i = 1; i <= n; i++) b[i] = inn();
  for (int i = 1; i <= n; i++) scanf("%d", &k[i]);
  for (int i = 1; i <= n; i++) p[i] = inn();
  return dfs(1, 2), !printf("%I64d\n", ans);
}
