#include <bits/stdc++.h>
using namespace std;
void execute();
int main() {
  ios::sync_with_stdio(false);
  execute();
}
long long n, u, r;
long long a[90];
long long b[90];
long long k[90];
long long p[90];
void one() {
  for (int i = n; i--;) a[i] ^= b[i];
}
void two() {
  for (int i = n; i--;) a[i + 40] = a[i];
  for (int i = n; i--;) a[i] = a[p[i] + 40] + r;
}
void untwo() {
  for (int i = n; i--;) a[i + 40] = a[i];
  for (int i = n; i--;) a[p[i]] = a[i + 40] - r;
}
long long score() {
  long long acc = 0;
  for (int i = n; i--;) acc += a[i] * k[i];
  return acc;
}
long long best;
inline void dfs(long long moves) {
  if (moves % 2 == 0) {
    best = max(best, score());
    if (not moves) return;
  }
  one();
  if (moves % 2 == 1) {
    best = max(best, score());
  }
  if (moves > 1) {
    two();
    dfs(moves - 2);
    untwo();
  }
  one();
  two();
  dfs(moves - 1);
  untwo();
}
void execute() {
  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];
  best = -(1ll << 60ll);
  dfs(u);
  if (u & 1) one();
  best = max(best, score());
  cout << best << endl;
}
