#include <bits/stdc++.h>
using namespace std;
long long a[33], b[33], c[33], p[33], k[33], n, u, r;
long long s, ans;
void solve(int x, bool t) {
  if (x > 0) {
    if (x % 2 == 0) {
      s = 0;
      for (int i = 1; i <= n; i++) s += a[i] * k[i];
      if (s > ans) ans = s;
    }
    if (t == false) {
      for (int i = 1; i <= n; i++) a[i] = a[i] ^ b[i];
      solve(x - 1, true);
      for (int i = 1; i <= n; i++) a[i] = a[i] ^ b[i];
    }
    for (int i = 1; i <= n; i++) c[i] = a[i];
    for (int i = 1; i <= n; i++) a[i] = c[p[i]] + r;
    solve(x - 1, false);
    for (int i = 1; i <= n; i++) c[i] = a[i];
    for (int i = 1; i <= n; i++) a[p[i]] = c[i] - r;
  } else {
    s = 0;
    for (int i = 1; i <= n; i++) s += a[i] * k[i];
    if (s > ans) ans = s;
  }
}
int main() {
  cin >> n >> u >> r;
  ans = -1111111111 * 1ll * 1111111111;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) cin >> k[i];
  for (int i = 1; i <= n; i++) cin >> p[i];
  solve(u, false);
  cout << ans;
  return 0;
}
