#include <bits/stdc++.h>
using namespace std;
long long A[31][40], a[40], b[40], k[40], p[40];
int n, u, r;
long long Best;
void Rec(int level, int last) {
  if ((u - level + 1) % 2 == 0) {
    long long Res = 0;
    for (int i = 1; i <= n; i++) Res += (A[level - 1][i] * k[i]);
    if (Res > Best) Best = Res;
  }
  if (level == u + 1) return;
  for (int i = 1; i <= n; i++) A[level][i] = A[level - 1][p[i]] + r;
  Rec(level + 1, 2);
  if (last == 2) {
    for (int i = 1; i <= n; i++) A[level][i] = A[level - 1][i] ^ b[i];
    Rec(level + 1, 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> u >> r;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) cin >> k[i];
  for (int i = 1; i <= n; i++) cin >> p[i];
  Best = -2000000000000000000LL;
  for (int i = 1; i <= n; i++) A[0][i] = a[i];
  Rec(1, 2);
  cout << Best << endl;
  return 0;
}
