#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e2 + 5;
long long a[maxn], b[maxn], p[maxn], k[maxn];
long long n, r;
long long ans() {
  long long ans_ = 0;
  for (long long i = 1; i <= n; i++) {
    ans_ += a[i] * k[i];
  }
  return ans_;
}
long long dfs(long long pos, bool shang) {
  if (pos == 0) {
    return ans();
  }
  long long max_ = -1e18;
  if (shang) {
    long long t[100];
    for (int i = 1; i <= n; i++) {
      t[i] = a[i];
    }
    for (long long i = 1; i <= n; i++) {
      a[i] = t[p[i]] + r;
    }
    max_ = dfs(pos - 1, 0);
    for (long long i = 1; i <= n; i++) {
      a[i] = t[i];
    }
    return max_;
  }
  if (!shang)
    if (pos % 2) {
      for (long long i = 1; i <= n; i++) a[i] ^= b[i];
      max_ = max(max_, ans());
      for (long long i = 1; i <= n; i++) a[i] ^= b[i];
    } else {
      max_ = max(max_, ans());
    }
  for (long long i = 1; i <= n; i++) {
    a[i] ^= b[i];
  }
  max_ = max(max_, dfs(pos - 1, 1));
  for (long long i = 1; i <= n; i++) {
    a[i] ^= b[i];
  }
  long long t[100];
  for (int i = 1; i <= n; i++) t[i] = a[i];
  for (long long i = 1; i <= n; i++) {
    a[i] = t[p[i]] + r;
  }
  max_ = max(max_, dfs(pos - 1, 0));
  for (long long i = 1; i <= n; i++) {
    a[i] = t[i];
  }
  return max_;
}
int main() {
  long long pos;
  cin >> n >> pos >> r;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> k[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> p[i];
  }
  cout << dfs(pos, 0) << endl;
  return 0;
}
