#include <bits/stdc++.h>
using namespace std;
int p[30], k[30], b[30], a[30], rp[30], tmp[30];
int n, u, r;
long long ans;
void backtrack(int at, int ql) {
  if (at == u || at == u - 2) {
    long long actans = 0;
    for (int i = (0), _ = (n); i < _; ++i) actans += a[i] * k[i];
    ans = max(ans, actans);
  }
  if (at >= u) return;
  for (int i = (0), _ = (n); i < _; ++i) tmp[i] = a[p[i]];
  for (int i = (0), _ = (n); i < _; ++i) a[i] = tmp[i];
  for (int i = (0), _ = (n); i < _; ++i) a[i] += r;
  backtrack(at + 1, 0);
  for (int i = (0), _ = (n); i < _; ++i) tmp[i] = a[rp[i]];
  for (int i = (0), _ = (n); i < _; ++i) a[i] = tmp[i];
  for (int i = (0), _ = (n); i < _; ++i) a[i] -= r;
  if (ql != 1) {
    for (int i = (0), _ = (n); i < _; ++i) a[i] ^= b[i];
    backtrack(at + 1, 1);
    for (int i = (0), _ = (n); i < _; ++i) a[i] ^= b[i];
  }
}
int main() {
  cin >> n >> u >> r;
  for (int i = (0), _ = (n); i < _; ++i) cin >> a[i];
  for (int i = (0), _ = (n); i < _; ++i) cin >> b[i];
  for (int i = (0), _ = (n); i < _; ++i) cin >> k[i];
  for (int i = (0), _ = (n); i < _; ++i) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = (0), _ = (n); i < _; ++i) rp[p[i]] = i;
  ans = -1000000000000000000;
  backtrack(0, 0);
  cout << ans << endl;
}
