#include <bits/stdc++.h>
using namespace std;
vector<int> b;
vector<int> k;
vector<int> p;
int n, u, r;
long double ans = -10000000000000;
inline void dfs(vector<int> v, int dep, bool is) {
  if ((u - dep) % 2 == 0) {
    long double ne = 0;
    for (int i = 0; i < n; i++) ne += (long double)(v[i] * k[i]);
    ans = max(ans, ne);
  }
  if (dep == u) return;
  vector<int> ne(n);
  dep++;
  if (!is) {
    for (int i = 0; i < n; i++) ne[i] = (v[i] ^ b[i]);
    dfs(ne, dep, true);
    ne.clear();
    ne.resize(n);
  }
  for (int i = 0; i < n; i++) ne[i] = v[p[i] - 1] + r;
  dfs(ne, dep, false);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  vector<int> a;
  a.clear();
  b.clear();
  k.clear();
  p.clear();
  cin >> n >> u >> r;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  b.resize(n);
  for (int i = 0; i < n; i++) cin >> b[i];
  k.resize(n);
  for (int i = 0; i < n; i++) cin >> k[i];
  p.resize(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  dfs(a, 0, false);
  cout << (long long)ans << endl;
  return 0;
}
