#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T &t, T f) {
  if (t > f) t = f;
}
template <class T>
void chmax(T &t, T f) {
  if (t < f) t = f;
}
const int INF = 2147483647 / 3;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
long long n, u, r;
long long a[40], b[40], k[40], p[40];
void ope1(long long aa[], long long aaa[]) {
  for (int i = 0; i < (n); ++i) aaa[i] = aa[i] ^ b[i];
}
void ope2(long long aa[], long long aaa[]) {
  for (int i = 0; i < (n); ++i) aaa[i] = aa[p[i] - 1] + r;
}
long long f(long long aa[], int ope, int l) {
  long long res = -1000000000000000000LL;
  if (l == 0) {
    res = 0;
    for (int i = 0; i < (n); ++i) res += aa[i] * k[i];
    return res;
  }
  if (l % 2 == 0) {
    res = 0;
    for (int i = 0; i < (n); ++i) res += aa[i] * k[i];
  }
  long long aaa[40];
  if (ope == 1) {
    ope2(aa, aaa);
    res = max(res, f(aaa, 2, l - 1));
  } else {
    ope1(aa, aaa);
    res = max(res, f(aaa, 1, l - 1));
    ope2(aa, aaa);
    res = max(res, f(aaa, 2, l - 1));
  }
  return res;
}
int main() {
  cin >> n >> u >> r;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) cin >> b[i];
  for (int i = 0; i < (n); ++i) cin >> k[i];
  for (int i = 0; i < (n); ++i) cin >> p[i];
  cout << max(f(a, 1, u), f(a, 2, u)) << endl;
  return 0;
}
