#include <bits/stdc++.h>
using namespace std;
const int N = 30;
int n, u, r;
long long A[N], B[N], P[N], K[N], T[N];
const long long min_result = -1000000000000000l;
inline void _xor() {
  for (int i = 0; i < n; i++) {
    A[i] ^= B[i];
  }
}
inline void permute() {
  long long T2[N];
  for (int i = 0; i < n; i++) {
    T2[i] = A[P[i]] + r;
  }
  for (int i = 0; i < n; i++) {
    A[i] = T2[i];
  }
}
long long solve(int u, bool last__xor = false) {
  if (u == 0) {
    long long result = 0;
    for (int i = 0; i < n; i++) {
      result += (long long)A[i] * K[i];
    }
    return result;
  }
  long long result = min_result;
  long long T[N];
  memcpy(T, A, sizeof A);
  if (!last__xor) {
    _xor();
    result = solve(u - 1, true);
    memcpy(A, T, sizeof A);
  }
  permute();
  result = max(result, solve(u - 1, false));
  memcpy(A, T, sizeof A);
  return result;
}
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]--;
  }
  long long result = min_result;
  for (int i = 0; i <= u; i += 2) {
    result = max(result, solve(u - i));
  }
  cout << result << endl;
  return 0;
}
