#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N; vector X(N); vector o(N-1); rep(i,N){ string s; cin >> s; X[i]=(s=="True"); } rep(i,N-1){ cin >> o[i]; } atcoder::segtree seg(N); rep(i,N) seg.set(i,1); rep(i,N-1){ int p; cin >> p; p--; int pj,pk; int ok = 0, ng = N; while(abs(ok-ng)>1){ int mid = (ok+ng)/2; if(seg.prod(0,mid)<=p) ok = mid; else ng = mid; } pj = ok; ok = 0, ng = N; while(abs(ok-ng)>1){ int mid = (ok+ng)/2; if(seg.prod(0,mid)<=p+1) ok = mid; else ng = mid; } pk = ok; X[pj] = calc(X[pj],o[pj],X[pk]); seg.set(pk,0); } cout << (X[0]?"True":"False") << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--) solve(); return 0; }