#include using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a> g; vector now,vis; void dfs(ll x,ll p){ if(vis[x]) return; vis[x]=1; for(auto i:g[x]){ if(i==p) continue; dfs(i,x); if(now[i]==1){ now[i]^=1; now[x]^=1; } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; g.resize(n); vector p(n,-1); replr(i,1,n){ cin >> p[i]; p[i]--; } string s(n,'x'); replr(i,1,n) cin >> s[i]; ll q; cin >> q; vector u(q),v(q); rep(i,q){ cin >> u[i] >> v[i]; u[i]--; v[i]--; g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } now.assign(n,-1); replr(i,1,n){ if(s[i]=='.') now[i]=0; else now[i]=1; } vis.assign(n,0); rep(i,n){ dfs(i,-1); if(now[i]==1){ cout << "No\n"; return 0; } } cout << "Yes\n"; }