#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[35][35];
int b[35];
int k[35];
int p[35];
long long ans;
long long judge(long long x) {
  long long t = 0;
  for (long long i = (0); i < (n); i++) {
    t += a[x][i] * k[i];
  }
  return t;
}
void dfs(long long i, bool flag) {
  if (i == u) {
    ans = max(ans, judge(i));
    return;
  }
  if ((u - i) % 2 == 0) {
    ans = max(ans, judge(i));
  }
  if (!flag) {
    for (long long j = (0); j < (n); j++) {
      a[i + 1][j] = a[i][j] ^ b[j];
    }
    dfs(i + 1, 1);
  }
  for (long long j = (0); j < (n); j++) {
    a[i + 1][j] = a[i][p[j] - 1] + r;
  }
  dfs(i + 1, 0);
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  for (long long i = (0); i < (n); i++) scanf("%d", &a[0][i]);
  for (long long i = (0); i < (n); i++) scanf("%d", &b[i]);
  for (long long i = (0); i < (n); i++) scanf("%d", &k[i]);
  for (long long i = (0); i < (n); i++) scanf("%d", &p[i]);
  ans = -20000000000LL;
  dfs(0, false);
  cout << ans << endl;
  return 0;
}
