#include <bits/stdc++.h>
using namespace std;
int64_t n, u, r;
int64_t a[31];
int64_t b[31];
int64_t k[31];
int64_t p[31];
int64_t calc(vector<int64_t>& state, int64_t steps_sofar, bool prev_isxor) {
  if (steps_sofar > u) return -(1LL << 60LL);
  int64_t dir_score = 0;
  for (int64_t i = 1; i <= n; i++) dir_score += state[i] * k[i];
  if (steps_sofar == u) return dir_score;
  int64_t pot_score = -(1LL << 60LL);
  if (!prev_isxor) {
    vector<int64_t> s1 = state;
    for (int64_t i = 1; i <= n; i++) s1[i] = s1[i] ^ b[i];
    pot_score = max(pot_score, calc(s1, steps_sofar + 1, true));
  }
  vector<int64_t> s2 = state;
  for (int64_t i = 1; i <= n; i++) s2[i] = state[p[i]] + r;
  pot_score = max(pot_score, calc(s2, steps_sofar + 1, false));
  if ((u - steps_sofar) % 2 == 0) {
    return max(dir_score, pot_score);
  } else {
    return pot_score;
  }
}
int main() {
  cin >> n >> u >> r;
  for (int64_t i = 1; i <= n; i++) cin >> a[i];
  for (int64_t i = 1; i <= n; i++) cin >> b[i];
  for (int64_t i = 1; i <= n; i++) cin >> k[i];
  for (int64_t i = 1; i <= n; i++) cin >> p[i];
  vector<int64_t> init;
  init.push_back(0);
  for (int64_t i = 1; i <= n; i++) init.push_back(a[i]);
  cout << calc(init, 0, false) << endl;
}
