#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
bool ch(int num) {
  int cur = 3;
  while (cur <= num) {
    if ((cur & num) == cur) {
      return 0;
    }
    cur <<= 1;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, u, r;
  cin >> n >> u >> r;
  vector<int> a(n), b(n), k(n), p(n);
  for (int &i : a) cin >> i;
  for (int &i : b) cin >> i;
  for (int &i : k) cin >> i;
  for (int &i : p) cin >> i, i--;
  long long ans = -1e18;
  if (u == 1) {
    long long val = 0;
    for (int i = 0; i < n; i++) {
      val += (a[i] ^ b[i]) * k[i];
    }
    ans = max(ans, val);
    val = 0;
    for (int i = 0; i < n; i++) {
      val += k[i] * (a[p[i]] + r);
    }
    ans = max(ans, val);
    cout << ans;
    return 0;
  }
  int u1 = u / 2 + (u % 2), u2 = u / 2;
  vector<int> vm1, vm2;
  for (int i = 0; i < (1 << u1); i++) {
    if (ch(i)) vm1.push_back(i);
  }
  for (int i = 0; i < (1 << u2); i++) {
    if (ch(i)) vm2.push_back(i);
  }
  vector<int> sh(u + 1);
  for (int i = 0; i <= u; i++) {
    sh[i] = 1 << i;
  }
  if (!(u % 2)) {
    long long val = 0;
    for (int i = 0; i < n; i++) {
      val += k[i] * a[i];
    }
    ans = max(ans, val);
  }
  for (int i : vm1) {
    for (int j : vm2) {
      if (i & 1 && sh[u2 - 1] & j) continue;
      int mask = (i << u1) + j;
      auto prev = a, cur = a;
      int oct = 0, zct = 0;
      int mt = __builtin_popcount(mask);
      for (int t = 0; t < u; t++) {
        if (mask & sh[t]) {
          oct++;
          for (int y = 0; y < n; y++) cur[y] ^= b[y];
        } else {
          zct++;
          for (int y = 0; y < n; y++) cur[y] = prev[p[y]] + r;
        }
        if ((zct + oct) % 2 == u % 2 && oct == mt) {
          long long val = 0;
          for (int y = 0; y < n; y++) {
            val += k[y] * cur[y];
          }
          ans = max(ans, val);
        }
        prev = cur;
      }
    }
  }
  cout << ans;
  return 0;
}
