#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)37;
const long long inf = (long long)1e18;
const int infint = (int)1e9;
long long a[MAXN], b[MAXN], p[MAXN], k[MAXN], tmp[MAXN];
long long t = 0, ans = -inf;
long long n, len, r;
void f(long long len, string s) {
  if (len % 2 == 0) {
    long long now = 0;
    for (int i = 1; i <= n; i++) now += tmp[i] * k[i];
    ans = max(ans, now);
    if (len == 0) return;
  }
  if (s.size() == 0 or s[s.size() - 1] == '1') {
    for (int i = 1; i <= n; i++) tmp[i] ^= b[i];
    f(len - 1, s + '0');
    for (int i = 1; i <= n; i++) tmp[i] ^= b[i];
    long long tmp2[37];
    for (int i = 1; i <= n; i++) tmp2[i] = tmp[i];
    for (int i = 1; i <= n; i++) tmp[i] = tmp2[p[i]] + r;
    f(len - 1, s + '1');
    for (int i = 1; i <= n; i++) tmp[i] = tmp2[i];
  } else {
    long long tmp2[37];
    for (int i = 1; i <= n; i++) tmp2[i] = tmp[i];
    for (int i = 1; i <= n; i++) tmp[i] = tmp2[p[i]] + r;
    f(len - 1, s + '1');
    for (int i = 1; i <= n; i++) tmp[i] = tmp2[i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> len >> r;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) tmp[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];
  f(len, "");
  cout << ans;
}
