#include <bits/stdc++.h>
using namespace std;
int nextint() {
  int t;
  scanf("%d", &t);
  return t;
}
long long nextll() {
  long long t;
  cin >> t;
  return t;
}
int a[31][31];
int b[31];
long long k[31];
int p[31];
long long res = -1000000000000000000LL;
int n;
int r;
long long calcres(int id) {
  long long res = 0;
  for (int i = 0; i < (n); i++) res += a[id][i] * k[i];
  return res;
}
void solve(int left, int canxor) {
  if (left == 0) {
    res = max(res, calcres(left));
  } else {
    if (left % 2 == 0) res = max(res, calcres(left));
    if (canxor) {
      for (int i = 0; i < (n); i++) a[left - 1][i] = a[left][i] ^ b[i];
      solve(left - 1, 0);
    }
    {
      for (int i = 0; i < (n); i++) a[left - 1][i] = a[left][p[i]] + r;
      solve(left - 1, 1);
    }
  }
}
int main() {
  n = nextint();
  int u = nextint();
  r = nextint();
  for (int i = 0; i < (n); i++) a[u][i] = nextint();
  for (int i = 0; i < (n); i++) b[i] = nextint();
  for (int i = 0; i < (n); i++) k[i] = nextint();
  for (int i = 0; i < (n); i++) p[i] = nextint() - 1;
  solve(u, 1);
  cout << res << endl;
}
