#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long ans;
long long n, u, r;
long long a[35], b[35], c[35], d[35], invd[35];
long long tmp[35];
void perform(long long *perm) {
  for (int i = 0; i < n; i++) tmp[i] = a[perm[i]];
  for (int i = 0; i < n; i++) a[i] = tmp[i];
}
void find_ans() {
  long long res = 0;
  for (int i = 0; i < n; i++) res += (a[i] * c[i]);
  ans = max(ans, res);
}
void solve(int id, int prev = -1) {
  if ((u - id) % 2 == 0) {
    find_ans();
  }
  if (id >= u) return;
  perform(d);
  for (int i = 0; i < n; i++) a[i] += r;
  solve(id + 1, 0);
  for (int i = 0; i < n; i++) a[i] -= r;
  perform(invd);
  if (prev != 1) {
    for (int i = 0; i < n; i++) a[i] ^= b[i];
    solve(id + 1, 1);
    for (int i = 0; i < n; i++) a[i] ^= b[i];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  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 >> c[i];
  for (int i = 0; i < n; i++) cin >> d[i], d[i]--;
  for (int i = 0; i < n; i++) invd[d[i]] = i;
  ans = -9e18;
  solve(0);
  cout << ans;
}
