#include <bits/stdc++.h>
using namespace std;
long long int a[33], b[33], p[33];
long long int k[33];
int sz;
long long int ans;
bool hasans;
int i, j, n, m, u;
long long int stk[33][33];
void search(int now, bool last) {
  int i;
  if (now > u) {
    long long int nowans = 0;
    for (i = 1; i <= n; i++) {
      nowans += stk[now][i] * k[i];
    }
    if (hasans) {
      if (nowans > ans) ans = nowans;
    } else
      ans = nowans, hasans = 1;
    return;
  }
  if (!last) {
    memcpy(stk[now + 1], stk[now], sz);
    for (i = 1; i <= n; i++) {
      stk[now + 1][i] ^= b[i];
    }
    search(now + 1, 1);
  }
  if ((u - now) % 2) {
    long long int nowans = 0;
    for (i = 1; i <= n; i++) {
      nowans += stk[now][i] * k[i];
    }
    if (hasans) {
      if (nowans > ans) ans = nowans;
    } else
      ans = nowans, hasans = 1;
  }
  for (i = 1; i <= n; i++) {
    stk[now + 1][i] = stk[now][p[i]] + m;
  }
  search(now + 1, 0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> u >> m;
  sz = sizeof(a);
  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];
  }
  memcpy(stk[1], a, sz);
  search(1, 0);
  cout << ans;
  return 0;
}
