#include <bits/stdc++.h>

using namespace std;

#define out(x) cout << #x << '=' << x << endl
#define out2(x, y) cout << #x << '=' << x << ',' << #y << '=' << y << endl 
#define no cout << "No" << endl; return
#define yes cout << "Yes" << endl; return
#define outvec(a) for (int v : a) { cout << v << ' '; } cout << endl
#define lowbit(x) (x & -x)
#define gcd __gcd 
#define inf 0x3f3f3f3f3f3f3f3fLL
#define infi 0x3f3f3f3f

using ll = long long;
using pii = pair<int, int>;


void solve() {
	int n, x, m;
	cin >> n >> x >> m;
	vector<vector<int>> graph(n + 1);
	
	vector<int> p(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		if (p[i] != -1) graph[p[i]].push_back(i);
	}
	
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}
	int dfn = 0;
	vector<int> dfns(n + 1);
	vector<int> dfne(n + 1);
	vector<int> idx(n + 1);
	function<int(int)> dfs = [&](int node) -> int {
		dfns[node] = dfne[node] = ++dfn;
		idx[dfn] = node;
		for (int next : graph[node]) {
			dfne[node] = dfs(next);
		}
		return dfne[node];
	};
	for (int i = 1; i <= n; i++) {
		if (p[i] == -1) {
			dfs(i);
			break;
		}
	}
	map<int, int> mp;
	vector<int> pre(n + 1);
	for (int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1];
		int back = v[idx[i]] ^ x;
		if (mp.count(back)) {
			pre[i] = max(pre[i], mp[back]);
		}
		mp[v[idx[i]]] = i;
	}
	for (int i = 1; i <= m; i++) {
		int q;
		cin >> q;
		int l = dfns[q];
		int r = dfne[q];
		
		if (pre[r] < l) {
			cout << "NO" << endl;
		} else {
			cout << "YES" << endl;
		}
	}
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    
    while (t--) {
    	solve();
	}
}
