#include <bits/stdc++.h>
const long long mod = 1000000007;
using namespace std;
template <typename T>
void printV(vector<T>& v) {
  for (int i = 0; i < (int)(v.size()); i++) cout << v[i] << " ";
  cout << endl;
}
template <typename T>
void printVs(vector<vector<T> >& v) {
  for (int i = 0; i < (int)(v.size()); i++) printV(v[i]);
}
long long cal(vector<long long> a, vector<long long>& b, vector<long long>& k,
              vector<long long>& p, int r, int u, bool can) {
  long long S = 0;
  for (int i = 0; i < (int)(a.size()); i++) S += a[i] * k[i];
  if (u == 0) return S;
  long long T = 0;
  if (can) {
    vector<long long> A = a;
    for (int i = 0; i < (int)(A.size()); i++) A[i] ^= b[i];
    T = cal(A, b, k, p, r, u - 1, 0);
  }
  vector<long long> A = a;
  for (int i = 0; i < (int)(A.size()); i++) A[i] = a[p[i] - 1] + r;
  long long U = cal(A, b, k, p, r, u - 1, 1);
  long long res = U;
  if (can) res = max(res, T);
  if (u % 2 == 0) res = max(res, S);
  return res;
}
int main(int argc, const char* argv[]) {
  int n, u, r;
  cin >> n >> u >> r;
  vector<long long> a(n), b(n), k(n), p(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(n); i++) cin >> b[i];
  for (int i = 0; i < (int)(n); i++) cin >> k[i];
  for (int i = 0; i < (int)(n); i++) cin >> p[i];
  cout << cal(a, b, k, p, r, u, 1) << endl;
}
