#include <bits/stdc++.h>
using namespace std;
long long a[35], b[35], p[35], k[35], ax[35][35];
int n, u, r;
long long ans = -1000000000000000000;
void func(int pos, int last) {
  if ((u - pos) % 2 == 0) {
    long long cans = 0;
    for (int i = 1; i <= n; i++) cans += ax[pos][i] * k[i];
    ans = (ans > cans) ? (ans) : (cans);
    if (pos == u) return;
  }
  if (last != 1) {
    for (int i = 1; i <= n; i++) ax[pos + 1][i] = ax[pos][i] ^ b[i];
    func(pos + 1, 1);
  }
  for (int i = 1; i <= n; i++) ax[pos + 1][i] = ax[pos][p[i]] + r;
  func(pos + 1, 2);
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  for (int i = 1; i <= n; i++) cin >> a[i], ax[0][i] = a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) cin >> k[i];
  for (int i = 1; i <= n; i++) cin >> p[i];
  func(0, 0);
  cout << ans << endl;
  return 0;
}
