#include <bits/stdc++.h>
using namespace std;
const int oo = 1 << 20;
const double PI = M_PI;
const double EPS = 1e-15;
const int MaxN = 32;
int N, U, R;
long long a[MaxN];
long long b[MaxN];
long long k[MaxN];
int p[MaxN];
long long answer = -(1LL << 40LL);
void combine(int u, int last) {
  if ((U - u) % 2 == 0) {
    long long ret = 0;
    for (int i = 0; i < N; i++) ret = ret + a[i] * k[i];
    answer = max(answer, ret);
  }
  if (u == U) return;
  long long aux[MaxN];
  for (int i = 0; i < N; ++i) aux[i] = a[i];
  for (int i = 0; i < N; ++i) a[i] = aux[p[i]] + R;
  combine(u + 1, 1);
  for (int i = 0; i < N; ++i) a[i] = aux[i];
  if (last != 0) {
    for (int i = 0; i < N; i++) a[i] = a[i] xor b[i];
    combine(u + 1, 0);
    for (int i = 0; i < N; i++) a[i] = a[i] xor b[i];
  }
}
int main() {
  cin.sync_with_stdio(false);
  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];
  for (int i = 0; i < N; i++) --p[i];
  combine(0, -1);
  cout << answer << endl;
  return 0;
}
