#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
vector<long long> a, b, k, p, temp, rev;
long long n, u, r;
long long rec(long rest) {
  long long res = -1000000000000000000ll;
  if (rest % 2 == 0) {
    res = 0;
    for (long i = 0; i < n; i++) res += a[i] * k[i];
  }
  if (rest == 0) return res;
  for (long i = 0; i < n; i++) temp[i] = a[p[i]] + r;
  a = temp;
  res = max(res, rec(rest - 1));
  for (long i = 0; i < n; i++) temp[i] = a[rev[i]] - r;
  a = temp;
  for (long i = 0; i < n; i++) a[i] ^= b[i];
  if (rest % 2 != 0) {
    long long t_res = 0;
    for (long i = 0; i < n; i++) t_res += a[i] * k[i];
    res = max(res, t_res);
  }
  for (long i = 0; i < n; i++) temp[i] = a[p[i]] + r;
  a = temp;
  if (rest - 2 >= 0) res = max(res, rec(rest - 2));
  for (long i = 0; i < n; i++) temp[i] = a[rev[i]] - r;
  a = temp;
  for (long i = 0; i < n; i++) a[i] ^= b[i];
  return res;
}
int main() {
  cin >> n >> u >> r;
  a.resize(n);
  b.resize(n);
  k.resize(n);
  p.resize(n);
  rev.resize(n);
  temp.resize(n);
  for (long i = 0; i < n; i++) cin >> a[i];
  for (long i = 0; i < n; i++) cin >> b[i];
  for (long i = 0; i < n; i++) cin >> k[i];
  for (long i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
    rev[p[i]] = i;
  }
  long long res = 0;
  res = rec(u);
  cout << res;
}
