#include <bits/stdc++.h>
using namespace std;
long long aa[33];
long long a[33], b[33], k[33], p[33];
long long n, u, r;
long long ans = -1e10;
void dfs(long long d, long long pre) {
  if ((u - d) % 2 == 0) {
    long long t = 0;
    for (int i = 1; i <= n; i++) t = t + a[i] * k[i];
    ans = max(ans, t);
  }
  if (d == u) return;
  long long tmp[33];
  for (int i = 1; i <= n; i++) tmp[i] = a[i];
  for (int i = 1; i <= n; i++) aa[i] = a[i];
  if (pre != 1) {
    for (int i = 1; i <= n; i++) a[i] = a[i] ^ b[i];
    dfs(d + 1, 1);
    for (int i = 1; i <= n; i++) a[i] = tmp[i];
  }
  for (int i = 1; i <= n; i++) aa[i] = a[p[i]] + r;
  for (int i = 1; i <= n; i++) a[i] = aa[i];
  dfs(d + 1, -1);
  for (int i = 1; i <= n; i++) a[i] = tmp[i];
}
int main() {
  cin >> n >> u >> r;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &b[i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &k[i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &p[i]);
  dfs(0, -1);
  cout << ans << endl;
}
