#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000,100000000")
using namespace std;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
long long ans = -inf;
long long n, u, r;
long long a[105][105], b[100005], k[100005], p[100005], c[100005];
void rec(long long v, bool flag) {
  if ((u - v) % 2 == 0) {
    long long rez = 0;
    for (long long i = 0; i < n; i++) rez += k[i] * a[v][i];
    ans = max(ans, rez);
    if (u == v) return;
  }
  if (flag == 0) {
    for (long long i = 0; i < n; i++) a[v + 1][i] = a[v][i] ^ b[i];
    rec(v + 1, 1);
  }
  for (long long i = 0; i < n; i++) a[v + 1][i] = a[v][p[i]] + r;
  rec(v + 1, 0);
}
int main(void) {
  cin >> n >> u >> r;
  for (long long i = 0; i < n; i++) cin >> a[0][i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  for (long long i = 0; i < n; i++) cin >> k[i];
  for (long long i = 0; i < n; i++) cin >> p[i], p[i]--;
  rec(0, 0);
  cout << ans << endl;
  return 0;
}
