#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int N = 30 + 7;
const int mod = 1e9 + 7;
const int B = 317;
int n;
int u, r;
int a[N][N];
int b[N];
int c[N];
int p[N];
long long foo(int x, bool f) {
  long long s = -1e18;
  if (x % 2 == 0) {
    s = 0;
    for (int i = 1; i <= n; i++) s += a[x][i] * 1LL * c[i];
  }
  if (x == 0) return s;
  if (f) {
    for (int i = 1; i <= n; i++) {
      a[x - 1][i] = a[x][i] ^ b[i];
    }
    s = max(s, foo(x - 1, false));
  }
  for (int i = 1; i <= n; i++) {
    a[x - 1][i] = a[x][p[i]] + r;
  }
  s = max(s, foo(x - 1, true));
  return s;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> u >> r;
  for (int i = 1; i <= n; i++) cin >> a[u][i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) cin >> p[i];
  cout << foo(u, true);
}
