#include using namespace std; const int N = 1e5 + 10; int n; struct Node { int color; int ls = -1, rs = -1; // 左儿子与右儿子 } tr[N]; void dfs(int u) { if (u == -1) return; if (tr[u].color == 0) tr[u].color = 1; else tr[u].color = 0; dfs(tr[u].ls), dfs(tr[u].rs); } int main() { #ifndef ONLINE_JUDGE freopen("20240602.in", "r", stdin); #endif // 读入 int n; cin >> n; for (int i = 1; i < n; i++) { int x; cin >> x; if (tr[x].ls == -1) // 赋值右儿子 tr[x].ls = i + 1; else // 左儿子 tr[x].rs = i + 1; } string s; // 注意:输入的是01串,不是0 1 cin >> s; for (int i = 1; i <= n; i++) tr[i].color = s[i - 1] - '0'; int q; cin >> q; while (q--) { int x; cin >> x; dfs(x); } for (int i = 1; i <= n; i++) printf("%d", tr[i].color); return 0; }