#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
int n, u, r;
long long a[33][33];
int b[33], k[33], p[33];
int tmp[33];
long long ans;
long long getval(int x) {
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += k[i] * a[x][i];
  return ans;
}
long long dfs(int step, int f) {
  long long res = -1e18;
  if ((u - step) % 2 == 0) res = getval(step);
  if (step == u) return res;
  if (!f) {
    for (int i = 1; i <= n; i++) a[step + 1][i] = a[step][i] ^ b[i];
    res = max(res, dfs(step + 1, 1));
  }
  for (int i = 1; i <= n; i++) a[step + 1][i] = a[step][p[i]] + r;
  res = max(res, dfs(step + 1, 0));
  return res;
}
int main() {
  scanf("%d %d %d", &n, &u, &r);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[0][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]);
  printf("%lld\n", dfs(0, 0));
  return 0;
}
