#include <bits/stdc++.h>
using namespace std;
int n, u, r, b[30], k[30], p[30], t;
long long solve(const vector<int>& a, int u) {
  long long score = 0, f = u & 1;
  for (int i = 0; i < n; ++i) score += (a[i] ^ (f * b[i])) * k[i];
  vector<int> v(30);
  for (f = 0; f < 2 && f < u; ++f) {
    for (int i = 0; i < n; ++i) v[i] = (a[p[i]] ^ (f * b[p[i]])) + r;
    score = max(score, solve(v, u - 1 - f));
  }
  return score;
}
long long solveFast(const vector<int>& a, int u) {
  long long score = 0;
  if (u & 1) {
    for (int i = 0; i < n; ++i) score += (a[i] ^ b[i]) * k[i];
  } else {
    for (int i = 0; i < n; ++i) score += a[i] * k[i];
  }
  if (u >= 1) {
    vector<int> v(n);
    for (int i = 0; i < n; ++i) v[i] = a[p[i]] + r;
    score = max(score, solveFast(v, u - 1));
  }
  if (u >= 2) {
    vector<int> v(n);
    for (int i = 0; i < n; ++i) v[i] = (a[p[i]] ^ b[p[i]]) + r;
    score = max(score, solveFast(v, u - 2));
  }
  return score;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> u >> r;
  vector<int> a;
  for (int i = 0; i < n; ++i) cin >> t, a.push_back(t);
  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], --p[i];
  cout << solveFast(a, u) << endl;
}
