#include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long n, u, r;
long long a[33], b[33], k[33], p[33];
long long ans = -INF;
void dfs(int now, int is) {
  if ((u - now) % 2 == 0) {
    long long gx = 0;
    for (int i = 1; i <= (n); ++i) gx += a[i] * k[i];
    ans = max(ans, gx);
  }
  if (now == u) return;
  vector<long long> as;
  for (int i = 1; i <= (n); ++i) as.push_back(a[i]);
  if (!is) {
    for (int i = 1; i <= (n); ++i) a[i] ^= b[i];
    dfs(now + 1, 1);
  }
  for (int i = 1; i <= (n); ++i) a[i] = as[p[i] - 1] + r;
  dfs(now + 1, 0);
}
int main() {
  scanf("%lld%lld%lld", &n, &u, &r);
  for (int i = 1; i <= (n); ++i) scanf("%lld", a + i);
  for (int i = 1; i <= (n); ++i) scanf("%lld", b + i);
  for (int i = 1; i <= (n); ++i) scanf("%lld", k + i);
  for (int i = 1; i <= (n); ++i) scanf("%lld", p + i);
  dfs(0, 0);
  printf("%lld\n", ans);
  return 0;
}
