#include <bits/stdc++.h>
using namespace std;
long long b[31], p[31], k[31], n, r, ans, anst;
void cal(long long a[]) {
  long long s = 0;
  int i;
  for (i = 1; i <= n; i++) s += a[i] * k[i];
  if (anst == 0 || ans < s) {
    anst = 1;
    ans = s;
  }
  return;
}
void dfs(long long a[], int u, int t) {
  long long nexta[31];
  int i;
  if (u % 2 == 0) cal(a);
  if (u == 0) return;
  if (t == 0) {
    for (i = 1; i <= n; i++) nexta[i] = a[i] ^ b[i];
    dfs(nexta, u - 1, 1);
  }
  for (i = 1; i <= n; i++) nexta[i] = a[p[i]] + r;
  dfs(nexta, u - 1, 0);
  return;
}
int main() {
  long long a[31];
  int u, i;
  cin >> n >> u >> r;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  for (i = 1; i <= n; i++) cin >> k[i];
  for (i = 1; i <= n; i++) cin >> p[i];
  anst = 0;
  dfs(a, u, 0);
  cout << ans << endl;
  return 0;
}
