#include <bits/stdc++.h>
using namespace std;
const int maxn = 39;
long long a[maxn];
int k[maxn];
int b[maxn];
int p[maxn];
int n, u, r;
int z[maxn];
long long res = -1e18;
void dfs(long long x[], int id, int last) {
  if (id > u) return;
  if ((u - id) % 2 == 0) {
    long long sum = 0;
    for (int i = 1; i <= n; ++i) sum += x[i] * 1LL * k[i];
    res = max(res, sum);
    if (u == id) return;
  }
  long long y[maxn];
  for (int i = 1; i <= n; ++i) y[i] = x[p[i]] + r;
  dfs(y, id + 1, 1);
  if (last) {
    for (int i = 1; i <= n; ++i) y[i] = (x[i] ^ b[i]);
    dfs(y, id + 1, 0);
  }
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &k[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
  dfs(a, 0, 1);
  printf("%lld\n", res);
  return 0;
}
