#include <bits/stdc++.h>
using namespace std;
long long mod_v(long long num) {
  if (num >= 0)
    return (num % 1000000007);
  else
    return (num % 1000000007 + 1000000007) % 1000000007;
}
long long bigmod(long long b, long long p, long long m) {
  long long res = 1 % m, x = b % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int n, u;
long long r;
long long a[35][35];
long long b[35];
long long k[35];
int p[35];
long long sum(int itr) {
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += a[itr][i] * k[i];
  }
  return ans;
}
long long backTrack(int itr, int f) {
  long long ans = -(2147383647LL * 2147383647LL);
  if ((u - itr) % 2 == 0) {
    ans = sum(itr);
  }
  if (itr == u) {
    return ans;
  }
  long long temp;
  if (f == 0) {
    for (int i = 1; i <= n; i++) {
      a[itr + 1][i] = a[itr][i] ^ b[i];
    }
    temp = backTrack(itr + 1, 1);
    ans = ((ans) > (temp) ? (ans) : (temp));
  }
  for (int i = 1; i <= n; i++) {
    a[itr + 1][i] = a[itr][p[i]] + r;
  }
  temp = backTrack(itr + 1, 0);
  ans = ((ans) > (temp) ? (ans) : (temp));
  return ans;
}
int main() {
  scanf("%d %d %I64d", &n, &u, &r);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[0][i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &b[i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &k[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  long long ans = backTrack(0, 0);
  printf("%I64d\n", ans);
}
