#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50;
const long long INF = 1e18;
int n, u, r;
long long a[MAXN][MAXN], b[MAXN], k[MAXN];
int p[MAXN];
long long sumUp(int iter) {
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += a[iter][i] * k[i];
  }
  return sum;
}
long long dfs(int iter, int isLastXor) {
  long long ans = -INF;
  if ((u - iter) % 2 == 0) ans = sumUp(iter);
  if (iter == u) return ans;
  if (isLastXor == 0) {
    for (int i = 1; i <= n; i++) {
      a[iter + 1][i] = a[iter][i] ^ b[i];
    }
    ans = max(ans, dfs(iter + 1, 1));
  }
  for (int i = 1; i <= n; i++) {
    a[iter + 1][i] = a[iter][p[i]] + r;
  }
  ans = max(ans, dfs(iter + 1, 0));
  return ans;
}
int main() {
  while (cin >> 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]);
    }
    printf("%I64d\n", dfs(0, 0));
  }
  return 0;
}
