#include <bits/stdc++.h>   using namespace std;   long long ans = -((long long)1 << 62);   int n, u, r;   int a[105];   int b[105];   int k[105];   int p[105];   void process(int m, int op) {     if (((u - m) & 1) == 0) {       long long an = 0;       for (int i = 1; i <= n; i++) an += a[i] * k[i];       ans = max(an, ans);     }     if (m == u) {       return;     }     if (op == 0) {       for (int i = 1; i <= n; i++) a[i] ^= b[i];       process(m + 1, 1);       for (int i = 1; i <= n; i++) a[i] ^= b[i];     }     vector<int> a1;     a1.push_back(1);     for (int i = 1; i <= n; i++) a1.push_back(a[i]);     for (int i = 1; i <= n; i++) a[i] = a1[p[i]] + r;     process(m + 1, 0);     for (int i = 1; i <= n; i++) a[i] = a1[i];   }   int main() {     scanf( %d %d %d , &n, &u, &r);     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]);     process(0, 0);     printf( %I64d , ans);     return 0;   }   