#include <bits/stdc++.h>
using namespace std;
int n, u, r;
int a[31], b[31], k[31], p[31];
long long int s = -333;
void calc(vector<int> &v) {
  int f[31];
  for (int j = 0; j < n; j++) {
    f[j] = a[j];
  }
  for (int j = 0; j < v.size(); j++) {
    if (v[j]) {
      for (int i = 0; i < n; i++) {
        f[i] ^= b[i];
      }
    } else {
      int g[31];
      for (int i = 0; i < n; i++) {
        g[i] = f[p[i] - 1] + r;
      }
      for (int j = 0; j < n; j++) {
        f[j] = g[j];
      }
    }
  }
  long long int c = 0;
  for (int j = 0; j < n; j++) {
    c += k[j] * f[j];
  }
  if (s != -333) {
    s = max(c, s);
  } else {
    s = c;
  }
}
void func(vector<int> v) {
  int d = v.size();
  if (v[d - 1] == 0) {
    for (int i = d; i < u; i++) {
      vector<int> f = v;
      f.push_back(1);
      if ((u - i - 1) % 2 == 0 && (u - i - 1 > 0)) calc(f);
      func(f);
      for (int j = i + 1; j < u; j++) {
        f.push_back(0);
      }
      calc(f);
      v.push_back(0);
      if ((u - i - 1) % 2 == 0 && (u - i - 1 > 0)) calc(v);
    }
  } else {
    if (d < u) {
      v.push_back(0);
      if ((u - d - 1) % 2 == 0 && (u - d - 1 > 0)) calc(v);
    }
    for (int i = d + 1; i < u; i++) {
      vector<int> f = v;
      f.push_back(1);
      if ((u - i - 1) % 2 == 0 && (u - i - 1 > 0)) calc(f);
      func(f);
      for (int j = i + 1; j < u; j++) {
        f.push_back(0);
      }
      calc(f);
      v.push_back(0);
      if ((u - i - 1) % 2 == 0 && (u - i - 1 > 0)) calc(v);
    }
  }
}
int solve() {
  cin >> n >> u >> r;
  for (int j = 0; j < n; j++) {
    cin >> a[j];
  }
  for (int j = 0; j < n; j++) {
    cin >> b[j];
  }
  for (int j = 0; j < n; j++) {
    cin >> k[j];
  }
  for (int j = 0; j < n; j++) {
    cin >> p[j];
  }
  vector<int> v1, v2;
  v1.push_back(0);
  v2.push_back(1);
  vector<int> v3, v4;
  v3.push_back(1);
  v4.push_back(0);
  for (int j = 0; j < u - 1; j++) {
    v3.push_back(0);
    v4.push_back(0);
  }
  if (u % 2 == 0) {
    s = 0;
    for (int j = 0; j < n; j++) {
      s += a[j] * k[j];
    }
  }
  calc(v4);
  calc(v3);
  func(v1);
  func(v2);
  cout << s << "\n";
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
