#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
template <class T>
inline T sqr(T x) {
  return x * x;
}
int n, u, r;
long long a[32];
long long b[32];
int p[32];
int p_1[32];
long long k[32];
long long res = LLONG_MIN;
long long calc() {
  long long res = 0;
  for (int i = 0; i < n; ++i) res += a[i] * 1ll * k[i];
  return res;
}
void rec(int x, bool was) {
  if (~(u - x) & 1) {
    res = max(res, calc());
    if (x == u) return;
  }
  if (!was) {
    long long save[32];
    memcpy(save, a, sizeof save);
    for (int i = 0; i < n; ++i) {
      a[i] ^= b[i];
    }
    rec(x + 1, true);
    memcpy(a, save, sizeof a);
  }
  long long t[32], save[32];
  memcpy(save, a, sizeof save);
  for (int i = 0; i < n; ++i) t[i] = a[p[i]] + r;
  memcpy(a, t, sizeof a);
  rec(x + 1, false);
  memcpy(a, save, sizeof a);
}
int main() {
  cin >> n >> u >> r;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> k[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
  }
  rec(0, 0);
  if (res == LLONG_MIN) ++*(int*)0;
  cout << res << endl;
  return 0;
}
