#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000LL;
int a[32], b[32], k[32], p[32];
int n, r;
long long Ans;
long long Max(long long a, long long b) { return a > b ? a : b; }
void input() {
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &k[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
  }
}
void dfs(int u, int x, const int c[]) {
  int t[32];
  if (u % 2 == 0) {
    long long ts = 0;
    for (int i = 1; i <= n; ++i) {
      ts += c[i] * k[i];
    }
    Ans = Max(Ans, ts);
  }
  if (!u) return;
  for (int i = 1; i <= n; ++i) {
    t[i] = c[i];
  }
  if (x) {
    for (int i = 1; i <= n; ++i) {
      t[i] = c[i] ^ b[i];
    }
    dfs(u - 1, 0, t);
  }
  for (int i = 1; i <= n; ++i) {
    t[i] = c[p[i]] + r;
  }
  dfs(u - 1, 1, t);
}
int main() {
  int u;
  Ans = -INF;
  scanf("%d%d%d", &n, &u, &r);
  input();
  dfs(u, 1, a);
  printf("%I64d\n", Ans);
  return 0;
}
