#include <bits/stdc++.h>
using namespace std;
int n, u, r;
long long int ans = -((1LL << 62) - 1);
bool last = false;
int a[10001];
int k[10001];
int b[10001];
int p[10001];
void backtrack(int cur) {
  int i;
  int tmp[10001];
  long long int s = 0;
  if ((cur & 1) != (u & 1)) {
    for (i = 1; i <= n; i++) s += (long long)a[i] * (long long)k[i];
    ans = max(ans, s);
  }
  if (cur == u + 1) return;
  if (!last) {
    last = true;
    for (i = 1; i <= n; i++) a[i] ^= b[i];
    backtrack(cur + 1);
    for (i = 1; i <= n; i++) a[i] ^= b[i];
    last = false;
  }
  bool tm = last;
  last = false;
  for (i = 1; i <= n; i++) tmp[i] = a[i];
  for (i = 1; i <= n; i++) a[i] = tmp[p[i]] + r;
  backtrack(cur + 1);
  for (i = 1; i <= n; i++) a[i] = tmp[i];
  last = tm;
}
int main() {
  int i;
  scanf("%d %d %d", &n, &u, &r);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (i = 1; i <= n; i++) scanf("%d", &k[i]);
  for (i = 1; i <= n; i++) scanf("%d", &p[i]);
  backtrack(1);
  cout << ans;
}
