#include <bits/stdc++.h>
using namespace std;
int n, u, r;
long long best = LLONG_MIN;
vector<int> b, k, p;
long long answer(vector<int>& a) {
  long long res = 0;
  for (int i = 0; i < n; ++i) res += (long long)a[i] * k[i];
  return res;
}
void solve(int u, vector<int>& a, bool one) {
  if (u == 0) {
    best = max(best, answer(a));
    return;
  }
  vector<int> newa(n);
  if (one) {
    for (int j = 0; j < n; ++j) newa[j] = a[j] ^ b[j];
    solve(u - 1, newa, 0);
  }
  for (int j = 0; j < n; ++j) newa[j] = a[p[j] - 1] + r;
  solve(u - 1, newa, 1);
}
int main() {
  scanf("%d%d%d", &n, &u, &r);
  vector<int> a;
  int x;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    a.push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    b.push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    k.push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    p.push_back(x);
  }
  if (u % 2 == 0) {
    for (int i = 0; i <= u; i += 2) solve(i, a, 1);
  } else {
    for (int i = 1; i <= u; i += 2) solve(i, a, 1);
  }
  cout << best << endl;
  return 0;
}
