#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[35];
int b[35];
int k[35];
int p[35];
int op[35];
int tmpa[35];
int tmmmma[35];
long long dfs(int index, const int ta[]) {
  if (index == u) {
    long long res = 0;
    for (int i = (0); i < ((n)); ++i) res += (long long)ta[i] * k[i];
    return res;
  }
  int tta[35];
  long long res = -(((long long)1) << 62);
  if (index == 0 || op[index - 1] != 0) {
    op[index] = 0;
    for (int i = (0); i < ((n)); ++i) tta[i] = ta[i] ^ b[i];
    res = max(res, dfs(index + 1, tta));
  }
  op[index] = 1;
  for (int i = (0); i < ((n)); ++i) tta[i] = ta[p[i]] + r;
  res = max(res, dfs(index + 1, tta));
  if ((u - index) % 2 == 0) {
    long long tmp = 0;
    for (int i = (0); i < ((n)); ++i) tmp += (long long)ta[i] * k[i];
    res = max(res, tmp);
  }
  return res;
}
int main(void) {
  cin >> n >> u >> r;
  for (int i = (0); i < ((n)); ++i) cin >> a[i];
  for (int i = (0); i < ((n)); ++i) cin >> b[i];
  for (int i = (0); i < ((n)); ++i) cin >> k[i];
  for (int i = (0); i < ((n)); ++i) cin >> p[i];
  for (int i = (0); i < ((n)); ++i) --p[i];
  cout << dfs(0, a) << endl;
}
