#include <bits/stdc++.h>
using namespace std;
long long ans, bo = 0, r, n, u;
long long B[40], K[40], P[40];
void rec(long long k, vector<long long> a, long long q) {
  long long i;
  if (k % 2 == 0) {
    long long s = 0;
    for (i = 0; i < n; i++) s += a[i] * K[i];
    if (bo) {
      if (ans < s) ans = s;
    } else
      ans = s, bo = 1;
    if (k == 0) return;
  }
  if (q) {
    vector<long long> b;
    for (i = 0; i < n; i++) b.push_back(a[i] ^ B[i]);
    rec(k - 1, b, 0);
  }
  vector<long long> b;
  for (i = 0; i < n; i++) b.push_back(a[P[i] - 1] + r);
  rec(k - 1, b, 1);
}
int main() {
  long long a[40], i;
  scanf("%I64d%I64d%I64d", &n, &u, &r);
  for (i = 0; i < n; i++) scanf("%I64d", &a[i]);
  for (i = 0; i < n; i++) scanf("%I64d", &B[i]);
  for (i = 0; i < n; i++) scanf("%I64d", &K[i]);
  for (i = 0; i < n; i++) scanf("%I64d", &P[i]);
  vector<long long> c;
  for (i = 0; i < n; i++) c.push_back(a[i]);
  rec(u, c, 1);
  printf("%I64d\n", ans);
  return 0;
}
