#include <bits/stdc++.h>
using namespace std;
long long ans = (long long)-1000000000 * 1000000000;
long long a[35], b[35], k[35], p[35], n, m, r;
long long check(long long x[35]) {
  long long u = 0;
  for (int i = 1; i <= n; i++) u += (long long)x[i] * k[i];
  return u;
}
void rec(int t, long long mas[35], bool last) {
  if ((m - t) % 2 == 0) ans = max(ans, check(mas));
  if (t == m) return;
  long long g[35];
  if (last == 0) {
    for (int i = 1; i <= n; i++) g[i] = (mas[i] ^ b[i]);
    rec(t + 1, g, 1);
  }
  for (int i = 1; i <= n; i++) g[i] = mas[p[i]] + r;
  rec(t + 1, g, 0);
}
int main() {
  cin >> n >> m >> r;
  for (int i = 1; i <= n; i++) cin >> 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];
  rec(0, a, 0);
  cout << ans << endl;
}
