#include #include using namespace std; int main(){ int N; cin >> N; vector P(N); for (int i = 1; i < N; i++){ cin >> P[i]; P[i]--; } string S; cin >> S; S = '.' + S; vector A(N); for (int i = 1; i < N; i++){ if (S[i] == '#'){ A[i] = 1; } } atcoder::dsu uf(N); int Q; cin >> Q; while (Q--){ int U, V; cin >> U >> V; U--; V--; uf.merge(U, V); } for (int i = 1; i < N; i++){ if (S[i] == '#'){ A[P[i]] ^= 1; } } bool ok = true; for (auto s : uf.groups()){ int x = 0; for (int v : s){ x ^= A[v]; } if (x == 1){ ok = false; } } if (ok){ cout << "Yes" << endl; } else { cout << "No" << endl; } }