#include <bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> b;
vector<int> k;
vector<int> p;
int n, u, r;
long long value(vector<int> v) {
  int len = v.size();
  long long ans = 0;
  for (int i = 0; i < len; i++) {
    ans = ans + v[i] * k[i];
  }
  return ans;
}
void print(vector<int> v) {
  int len = v.size();
  for (int i = 0; i < len; i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
long long f(vector<int> v, int last, int u) {
  vector<int> v2(v.size());
  if (u == 0) {
    return value(v);
  }
  int len = v.size();
  for (int i = 0; i < len; i++) {
    v2[i] = v[p[i] - 1] + r;
  }
  long long ans = f(v2, 0, u - 1);
  if (last == 0) {
    for (int i = 0; i < len; i++) {
      v2[i] = v[i] ^ b[i];
    }
    ans = max(ans, f(v2, 1, u - 1));
  }
  if (last == 1) {
    if (u % 2 == 0) {
      ans = max(ans, value(v));
    } else {
      for (int i = 0; i < len; i++) {
        v2[i] = v[i] ^ b[i];
      }
      ans = max(ans, value(v2));
    }
  }
  return ans;
}
int main() {
  cin >> n >> u >> r;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    b.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    k.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    p.push_back(x);
  }
  cout << f(a, 0, u) << endl;
}
