#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100;
int n, u, r;
vector<int> a, b, k, p;
long long ans = 0;
inline void brute(int pos, const vector<int> &now, bool Xor) {
  if (!((u - pos) & 1)) {
    long long sum = 0;
    for (int i = 0; i < n; i++) sum += (long long)now[i] * (long long)k[i];
    ans = max(sum, ans);
  }
  if (u == pos) return;
  if (!Xor) {
    vector<int> newv(n, 0);
    for (int i = 0; i < n; i++) newv[i] = (now[i] ^ b[i]);
    brute(pos + 1, newv, 1);
  }
  vector<int> newv(n, 0);
  for (int i = 0; i < n; i++) newv[i] = now[p[i]] + r;
  brute(pos + 1, newv, 0);
}
int main() {
  while (scanf("%d%d%d", &n, &u, &r) >= 1) {
    a.resize(n);
    b.resize(n);
    k.resize(n);
    p.resize(n);
    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 = -(long long)(1e18);
    brute(0, a, 0);
    printf("%I64d\n", ans);
  }
  return 0;
}
