#include <bits/stdc++.h>
using namespace std;
int n, u, r;
vector<int> a, b, k, p;
long long s, current;
int lastChoice;
void input();
void solve();
void go(int k);
int main() {
  input();
  solve();
}
void input() {
  cin >> n >> u >> r;
  a.resize(n);
  b.resize(n);
  k.resize(n);
  p.resize(n);
  int val;
  for (int i = 0; i <= n - 1; ++i) {
    cin >> val;
    a[i] = val;
  }
  for (int i = 0; i <= n - 1; ++i) {
    cin >> val;
    b[i] = val;
  }
  for (int i = 0; i <= n - 1; ++i) {
    cin >> val;
    k[i] = val;
  }
  for (int i = 0; i <= n - 1; ++i) {
    cin >> val;
    p[i] = val - 1;
  }
}
void solve() {
  s = (long long)(-1e12);
  lastChoice = 1;
  go(1);
  cout << s;
}
void go(int x) {
  if ((x - 1) % 2 == u % 2) {
    long long sum = 0;
    for (int i = 0; i <= n - 1; ++i) sum += a[i] * k[i];
    s = max(s, sum);
  }
  if (x >= u + 1) {
    return;
  }
  vector<int> _a(n);
  int _lastChoice = lastChoice;
  for (int i = 0; i <= n - 1; ++i) _a[i] = a[i];
  lastChoice = 1;
  for (int i = 0; i <= n - 1; ++i) {
    a[i] = _a[p[i]] + r;
  }
  go(x + 1);
  for (int i = 0; i <= n - 1; ++i) a[i] = _a[i];
  lastChoice = _lastChoice;
  if (lastChoice == 0) {
    return;
  } else {
    _lastChoice = lastChoice;
    for (int i = 0; i <= n - 1; ++i) _a[i] = a[i];
    lastChoice = 0;
    for (int i = 0; i <= n - 1; ++i) {
      a[i] = (_a[i] ^ b[i]);
    }
    go(x + 1);
    lastChoice = _lastChoice;
    for (int i = 0; i <= n - 1; ++i) a[i] = _a[i];
  }
}
