#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MAXN 500500
#define MAXSZB (2*MAXN)
#define MAXSZ (2*MAXSZB)
#define MAXQ 500500
int a[MAXSZ];
int c[MAXSZ];
vector<int> pos[MAXN];
int ans[MAXQ];
struct BitwiseTree {
int sz;
vector<int> bit;
BitwiseTree(int s) {
sz=s;
bit=vector<int>(s+1, 0LL);
}
void update(int i, int v) {
for(;i<=sz;i+=(i&(-i))) bit[i]+=v;
}
int query(int i) {
int ans=0;
for(;i>0;i-=(i&(-i))) ans+=bit[i];
return ans;
}
int query(int l, int r) {
return query(r)-query(l-1);
}
};
int fstAfter(int v, int i) {
auto p=upper_bound(pos[v].begin(), pos[v].end(), i);
return *p;
}
int32_t main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, x;
cin >> n >> x;
int szb=2*n, sz=2*szb;
for(int i=1;i<=szb;i++) cin >> a[i];
for(int i=1;i<=szb;i++) cin >> c[i];
for(int i=1;i<=szb;i++) {
a[i+szb]=a[i];
c[i+szb]=c[i];
}
BitwiseTree st(sz);
BitwiseTree en(sz);
int cnt=0;
for(int i=1;i<=sz;i++) pos[a[i]].push_back(i);
for(int i=1;i<=n;i++) st.update(pos[i].front(), 1LL);
for(int i=1;i<=n;i++) {
int af=fstAfter(i, pos[i].front());
cnt+=st.query(af+1, szb);
en.update(af, 1LL);
}
vector<pair<int, pair<int, int>>> vc;
int q;
cin >> q;
vc.reserve(szb+q);
for(int i=1;i<=szb;i++) {
vc.push_back({cnt, {0, i}});
int af=fstAfter(a[i], i);
st.update(i, -1);
st.update(af, 1);
en.update(af, -1);
en.update(szb+i, 1);
cnt-=st.query(af+1, i+szb-1);
cnt+=en.query(i+1, af-1);
}
for(int i=1;i<=q;i++) {
int k;
cin >> k;
k=n*n-k;
vc.push_back({k, {1, i}});
}
sort(vc.begin(), vc.end());
for(int i=1;i<=q;i++) ans[i]=(int)1e18L;
int mn=(int)1e18L;
for(auto pr : vc) {
if(pr.second.first) {
int qi=pr.second.second;
ans[qi]=min(ans[qi], mn);
} else {
mn=min(mn, c[pr.second.second]);
}
}
reverse(vc.begin(), vc.end());
mn=(int)1e18L;
for(auto pr : vc) {
if(pr.second.first) {
int qi=pr.second.second;
ans[qi]=min(ans[qi], mn-pr.first*x);
} else {
mn=min(mn, c[pr.second.second]+pr.first*x);
}
}
for(int i=1;i<=q;i++) cout << ans[i] << "\n";
return 0;
}