#include <bits/stdc++.h>
const int N = 35;
bool vis[N];
long long ans = 0;
int n, u, r, p[N], K[N], b[N];
long long a[N];
void dfs(int idx) {
  if ((u - idx) % 2 == 0) {
    long long get = 0;
    for (int i = 1; i <= n; ++i) get += (long long)a[i] * K[i];
    if (get > ans) ans = get;
  }
  if (u == idx) return;
  long long use[n + 1];
  for (int i = 1; i <= n; ++i) use[i] = a[i];
  if (idx == 0 || vis[idx - 1] == 0) {
    vis[idx] = 1;
    for (int i = 1; i <= n; ++i) a[i] = a[i] ^ b[i];
    dfs(idx + 1);
    vis[idx] = 0;
  }
  for (int i = 1; i <= n; ++i) a[i] = use[p[i]] + r;
  dfs(idx + 1);
  for (int i = 1; i <= n; ++i) a[i] = use[i];
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &K[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
  ans = -(1ll << 60);
  memset(vis, 0, sizeof vis);
  dfs(0);
  std::cout << ans << std::endl;
  return 0;
}
