#include <bits/stdc++.h>
using namespace std;
const int MAXN = 32;
const long long INF = 0x123456789ABCDEFLL;
int n, u, r;
int a[MAXN], b[MAXN], k[MAXN], p[MAXN];
long long ans;
void gao(int m, bool flag, int a[MAXN]) {
  if (m % 2 == 0) {
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += 1LL * a[i] * k[i];
    }
    ans = max(ans, sum);
  }
  if (m == 0) {
    return;
  }
  if (flag) {
    for (int i = 0; i < n; ++i) {
      a[i] ^= b[i];
    }
    gao(m - 1, false, a);
    for (int i = 0; i < n; ++i) {
      a[i] ^= b[i];
    }
  }
  int aa[MAXN];
  for (int i = 0; i < n; ++i) {
    aa[i] = a[p[i]] + r;
  }
  gao(m - 1, true, aa);
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &k[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }
  ans = -INF;
  gao(u, true, a);
  cout << ans << endl;
  return 0;
}
