#include <bits/stdc++.h>
using namespace std;
int a[30], b[30], k[30], p[30];
int n, u, r;
int A[30];
long long sum, ans = -1ll * (int)HUGE_VAL * (int)HUGE_VAL;
void rec(char v, int m) {
  if ((u - m) % 2 == 0) {
    sum = 0;
    for (int i = 0; i < n; ++i) sum += 1ll * A[i] * k[i];
    ans = max(ans, sum);
  }
  if (u == m) return;
  if (v == 1) {
    for (int i = 0; i < n; ++i) A[i] ^= b[i];
    rec(2, m + 1);
  } else {
    int A1[30];
    memcpy(A1, A, sizeof(A1));
    ;
    for (int i = 0; i < n; ++i) A[i] = A1[p[i]] + r;
    rec(1, m + 1);
    memcpy(A, A1, sizeof(A));
    ;
    for (int i = 0; i < n; ++i) A[i] = A1[p[i]] + r;
    rec(2, m + 1);
  }
}
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]--;
  }
  memcpy(A, a, sizeof(A));
  ;
  rec(1, 0);
  memcpy(A, a, sizeof(A));
  ;
  rec(2, 0);
  cout << ans << endl;
  return 0;
}
