#include <bits/stdc++.h>
using namespace std;
const long long N = 30 + 5;
long long n, u, r;
long long a[N];
long long b[N];
long long k[N];
long long p[N];
long long inf = LLONG_MIN;
long long f(long long step, long long arr[N], long long last) {
  long long tng = -inf;
  if (step % 2 == 0) {
    tng = 0;
    for (int i = 0; i < n; i++) {
      tng += arr[i] * k[i];
    }
  }
  long long ans = -inf;
  if (step == 0) {
    ans = 0;
    for (long long i = 0; i < n; i++) {
      ans += arr[i] * k[i];
    }
    return ans;
  }
  if (last == 0) {
    for (long long i = 0; i < n; i++) {
      arr[i] = arr[i] ^ b[i];
    }
    ans = max(ans, f(step - 1, arr, 1));
    for (long long i = 0; i < n; i++) {
      arr[i] = arr[i] ^ b[i];
    }
  }
  long long tmp[N];
  for (long long i = 0; i < n; i++) {
    tmp[i] = arr[p[i] - 1] + r;
  }
  long long png = -inf;
  if (step % 2 == 0) {
    png = 0;
    for (int i = 0; i < n; i++) {
      png += arr[i] * k[i];
    }
  }
  ans = max({tng, png, ans, f(step - 1, tmp, 0)});
  return ans;
}
int main() {
  cin >> n >> u >> r;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> k[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> p[i];
  }
  cout << f(u, a, 0);
}
