#include <bits/stdc++.h>
using namespace std;
int n, u, r;
long long maxsum = numeric_limits<long long>::min();
vector<int> b, k, p;
vector<vector<int> > a;
void rec(int lev, int op) {
  if (((u - lev) & 1UL) == 0) {
    long long val = 0;
    for (int i = 0; i < (n); ++i) val += (long long)(a[lev][i]) * k[i];
    maxsum = max(val, maxsum);
  }
  if (u == lev) return;
  if (op) {
    for (int i = 0; i < (n); ++i) {
      a[lev + 1][i] = a[lev][i] ^ b[i];
    }
    rec(lev + 1, 0);
  }
  for (int i = 0; i < (n); ++i) {
    a[lev + 1][i] = a[lev][p[i] - 1] + r;
  }
  rec(lev + 1, 1);
}
int main(int argc, char** argv) {
  istream* is = &cin;
  ostream* os = &cout;
  if (argc >= 2) {
    is = new ifstream(argv[1]);
  }
  if (argc >= 3) {
    os = new ofstream(argv[2]);
  }
  cin >> n >> u >> r;
  b.resize(n);
  p.resize(n);
  k.resize(n);
  a.resize(u + 1, vector<int>(n, 0));
  for (int i = 0; i < (n); ++i) cin >> a[0][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];
  rec(0, 1);
  *os << maxsum << endl;
  if (is != &cin) delete is;
  if (os != &cout) {
    os->flush();
    delete os;
  }
  return 0;
}
