#include <bits/stdc++.h>
using namespace std;
const int N = 30;
long long ans = -(long long)1e18;
int n, u, r, a[N], b[N], k[N], p[N], cura[N];
void go(int cn, int cm, bool lastxor = false) {
  if ((cn == 0) && (cm == 0)) {
    long long res = 0;
    for (int i = 0; i < n; ++i) res += a[i] * k[i];
    ans = max(ans, res);
    return;
  }
  if (cn > 0) {
    for (int i = 0; i < n; ++i) cura[i] = a[p[i]] + r;
    for (int i = 0; i < n; ++i) a[i] = cura[i];
    go(cn - 1, cm, false);
    for (int i = 0; i < n; ++i) cura[p[i]] = a[i] - r;
    for (int i = 0; i < n; ++i) a[i] = cura[i];
  }
  if (!lastxor && (cm > 0)) {
    for (int i = 0; i < n; ++i) a[i] ^= b[i];
    go(cn, cm - 1, true);
    for (int i = 0; i < n; ++i) a[i] ^= b[i];
  }
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &k[i]);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  while (u >= 0) {
    for (int i = 0; i <= u; ++i) go(i, u - i, false);
    u -= 2;
  }
  cout << ans << endl;
  return 0;
}
