#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;

inline int power(int a, int b, int mod=M) {
    int x = 1;
    a %= mod;
    while (b) {
        if (b & 1) x = (x * a) % mod; 
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}


//_ ***************************** START Below *******************************




vector<tuple<int,int,string>> a;

vector<string> consistency(int n){

    vector<int>f1(26, 0);
    vector<int>f2(26, 0);
    
    f1[0]++;
    f2[0]++;
    
    vector<string> ans;
    for(int i=0; i<n; i++){
        
        int tar = get<0>(a[i]);
        int freq = get<1>(a[i]);
        string wrd = get<2>(a[i]);

        
        for(auto& ch : wrd){
            if(tar == 1) f1[ch-'a'] += freq;
            else f2[ch-'a'] += freq;
        }
        
        int s = 0;
        while(s<26 && f1[s] == 0) s++;

        int e = 25;
        while(e>s && f2[e] == 0) e--;
        
        //* guranteed case =>  
        //*     either  s = xxxx yyyyy zzz ....   OR   s = xxxx
        //*        and  t = xx  or xxxx or xxxxx 
        if(e==s){
            bool moreInS = false;
            for(int j=s+1; j<26; j++){
                if(f1[j] != 0) {
                    moreInS = true;
                    break;
                }
            }
            if(moreInS) ans.push_back("NO");
            
            else if(f2[s] > f1[s]) ans.push_back("YES");
            else ans.push_back("NO");
        }
        else{
            ans.push_back("YES");
        }

    }


    return ans;

}















vector<string> practice(int n){


}





void solve() {
    
    int n;
    cin>> n;
    
    a.resize(n);
    for(int i=0; i<n; i++){
        int x, y;
        string z;
        cin >> x >> y >> z;
        a[i] = {x,y,z};
    }
    
    auto ans = consistency(n);
    for(auto& it : ans) cout << it << endl;


}





int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}