#include <bits/stdc++.h>
long long a[31][30], b[30], K[30], p[30];
long long n, u, r;
long long backtr(int step, bool wasXOR) {
  long long ret = -999999999 * 1000LL;
  if ((u - step) % 2 == 0) {
    ret = 0;
    for (int i = 0; i < n; i++) ret += a[step][i] * K[i];
  }
  if (step < u) {
    long long temp;
    if (!wasXOR) {
      for (int i = 0; i < n; i++) a[step + 1][i] = a[step][i] ^ b[i];
      temp = backtr(step + 1, true);
      if (ret < temp) ret = temp;
    }
    for (int i = 0; i < n; i++) a[step + 1][i] = a[step][p[i] - 1] + r;
    temp = backtr(step + 1, false);
    if (ret < temp) ret = temp;
  }
  return ret;
}
int main(void) {
  scanf("%I64d %I64d %I64d", &n, &u, &r);
  for (int i = 0; i < n; i++) scanf("%I64d", a[0] + i);
  for (int i = 0; i < n; i++) scanf("%I64d", b + i);
  for (int i = 0; i < n; i++) scanf("%I64d", K + i);
  for (int i = 0; i < n; i++) scanf("%I64d", p + i);
  printf("%I64d\n", backtr(0, 0));
  return 0;
}
