#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[35], b[35], k[35], p[35];
int seq[35];
int op = 0;
long long ans;
bool bans = false;
void dfs(int nom) {
  int i;
  if (!((u - nom) & 1)) {
    long long res = 0;
    for (i = 1; i <= n; i++) {
      res += ((long long)a[i]) * k[i];
    }
    if (!bans || res > ans) {
      bans = true;
      ans = res;
    }
  }
  if (nom == u) {
    return;
  }
  int a0[35];
  if (nom == 0 || seq[nom - 1] != 1) {
    seq[nom] = 1;
    for (i = 1; i <= n; i++) {
      a0[i] = a[i];
      a[i] ^= b[i];
    }
    dfs(nom + 1);
    for (i = 1; i <= n; i++) {
      a[i] = a0[i];
    }
  }
  seq[nom] = 2;
  for (i = 1; i <= n; i++) {
    a0[i] = a[i];
  }
  for (i = 1; i <= n; i++) {
    a[i] = a0[p[i]] + r;
  }
  dfs(nom + 1);
  for (i = 1; i <= n; i++) {
    a[i] = a0[i];
  }
}
int main() {
  cin >> n >> u >> r;
  int i;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  for (i = 1; i <= n; i++) cin >> k[i];
  for (i = 1; i <= n; i++) cin >> p[i];
  dfs(0);
  cout << ans << endl;
  return 0;
}
