#include <bits/stdc++.h>
using namespace std;
int N, M, r;
int a[110], b[110], k[110], p[110];
long long ans;
int temp[110];
void calc(int dp) {
  if (dp > M) return;
  if ((M - dp) % 2 == 0) {
    long long cur = 0;
    for (int i = 0; i < N; i++) cur += (long long)a[i] * k[i];
    ans = max(ans, cur);
  } else {
    long long cur = 0;
    for (int i = 0; i < N; i++) cur += (long long)(a[i] ^ b[i]) * k[i];
    ans = max(ans, cur);
  }
  if (M == dp) return;
  for (int i = 0; i < N; i++) a[i] ^= b[i];
  for (int i = 0; i < N; i++) temp[i] = a[p[i]] + r;
  memcpy(a, temp, sizeof(int) * N);
  calc(dp + 2);
  for (int i = 0; i < N; i++) temp[p[i]] = a[i] - r;
  memcpy(a, temp, sizeof(int) * N);
  for (int i = 0; i < N; i++) a[i] ^= b[i];
  for (int i = 0; i < N; i++) temp[i] = a[p[i]] + r;
  memcpy(a, temp, sizeof(int) * N);
  calc(dp + 1);
  for (int i = 0; i < N; i++) temp[p[i]] = a[i] - r;
  memcpy(a, temp, sizeof(int) * N);
}
int main() {
  scanf("%d%d%d", &N, &M, &r);
  for (int i = 0; i < N; i++) scanf("%d", &a[i]);
  for (int i = 0; i < N; i++) scanf("%d", &b[i]);
  for (int i = 0; i < N; i++) scanf("%d", &k[i]);
  for (int i = 0; i < N; i++) scanf("%d", &p[i]);
  ans = -0x3fffffffffffffff;
  for (int i = 0; i < N; i++) p[i]--;
  calc(0);
  printf("%I64d\n", ans);
  return 0;
}
