#include <bits/stdc++.h>
using namespace std;
long long a[50][50], b[50], k[50], p[50];
long long makesum(int t, int n) {
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += (a[t][i] * k[i]);
  return ans;
}
long long findans(int t, int u, int n, bool q, int r) {
  long long maxx = 100000000;
  maxx *= -1000000000;
  if ((u - t) % 2 == 0) maxx = makesum(t, n);
  if (u == t) return maxx;
  if (!q) {
    for (int i = 1; i <= n; i++) a[t + 1][i] = (a[t][i] ^ b[i]);
    maxx = max(maxx, findans(t + 1, u, n, 1, r));
  }
  for (int i = 1; i <= n; i++) a[t + 1][i] = a[t][p[i]] + r;
  maxx = max(maxx, findans(t + 1, u, n, 0, r));
  return maxx;
}
int main() {
  int n, u, r;
  while (scanf("%d %d %d", &n, &u, &r) != EOF) {
    for (int i = 1; i <= n; i++) cin >> a[0][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];
    cout << findans(0, u, n, 0, r) << endl;
  }
  return 0;
}
