#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[30], b[30], k[30], p[30];
long long maximum = -1000000000000ll;
void best(int input[30], int remaining, bool prev) {
  if (remaining == 0) {
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      ans += input[i] * k[i];
    }
    if (ans > maximum) {
      maximum = ans;
    }
    return;
  }
  if (!prev) {
    int a1[30];
    for (int i = 0; i < n; i++) {
      a1[i] = input[i] ^ b[i];
    }
    best(a1, remaining - 1, true);
  }
  if (remaining == 2 || remaining == 3) {
    best(input, remaining - 2, false);
  }
  int a2[30];
  for (int i = 0; i < n; i++) {
    a2[i] = input[p[i]] + r;
  }
  best(a2, remaining - 1, false);
}
int main() {
  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];
    p[i]--;
  }
  best(a, u, false);
  cout << maximum << endl;
}
