#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 33;
int n, u, r, a[MAXN][MAXN], b[MAXN], k[MAXN], p[MAXN];
long long ans = -INF64;
void gen(int step, bool lx) {
  if (((u - step) & 1) == 0) {
    long long cur = 0;
    for (int i = 0; i < (int)(n); i++) cur += a[step][i] * k[i];
    ans = max(ans, cur);
  } else {
    long long cur = 0;
    for (int i = 0; i < (int)(n); i++) cur += (a[step][i] ^ b[i]) * k[i];
    ans = max(ans, cur);
  }
  if (step != u) {
    if (!lx || step == u - 1) {
      for (int i = 0; i < (int)(n); i++) a[step + 1][i] = a[step][i] ^ b[i];
      gen(step + 1, true);
    }
    for (int i = 0; i < (int)(n); i++) a[step + 1][i] = a[step][p[i]] + r;
    gen(step + 1, false);
  }
}
int main() {
  cin >> n >> u >> r;
  for (int i = 0; i < (int)(n); i++) cin >> a[0][i];
  for (int i = 0; i < (int)(n); i++) cin >> b[i];
  for (int i = 0; i < (int)(n); i++) cin >> k[i];
  for (int i = 0; i < (int)(n); i++) cin >> p[i];
  for (int i = 0; i < (int)(n); i++) p[i]--;
  gen(0, false);
  cout << ans << endl;
  return 0;
}
