#include <bits/stdc++.h>
using namespace std;

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;

const int MAX = 26, INF = 1e7;
vector<pair<string, int>> pats, texts;
int q, n, m;

int getIdx(char c){ return c-'a'; }

struct node{
    node* fail;
    node* child[MAX];
    int time;

    node(){
        memset(child, 0, sizeof(child));
        time = INF;
        fail = NULL;
    }

    void insert(string &str, int pos, int len, int id){
        if(pos == len){
            time = min(time, id);
        }else{
            int idx = getIdx(str[pos]);
            if(!child[idx]){
                child[idx] = new node();
                child[idx]->insert(str, pos+1, len, id);
            }else{
                child[idx]->insert(str, pos+1, len, id);
            }
        }
    }

};

void move(node* &k, int c){
    while(!k->child[c]) k = k->fail;
    k = k->child[c];
}

node* buildAhoTree(){
    node* root = new node();
    root->fail = root;
    rep(i, 0, n-1){
        root->insert(pats[i].first, 0, sz(pats[i].first), pats[i].second);
    }

    queue<node*> q;
    rep(i, 0, MAX-1){
        if(root->child[i]){
            root->child[i]->fail = root;
            q.push(root->child[i]);
        }else root->child[i] = root;
    }

    while(!q.empty()){
        node* cur = q.front();
        q.pop();

        rep(i, 0, MAX-1){
            if(cur->child[i]){
                q.push(cur->child[i]);
                node* k = cur->fail;
                move(k, i);
                cur->child[i]->fail = k;
            }
        }
    }

    return root;
};

bool match(node* root, string T, int id){
    node* k = root;
    rep(i, 0, sz(T)-1){
        int idx = getIdx(T[i]);
        while(k != root && !k->child[idx]) k = k->fail;
        k = k->child[idx];
        if(k->time < id) return 1;
    }
    return 0;
}

void solve(int testcase) {
    cin >> q;
    rep(i, 1, q){
        int t;
        string str;
        cin >> t >> str;
        if(t==0) pats.push_back({str, i});
        else texts.push_back({str, i});
    }
    n = sz(pats);
    m = sz(texts);

    node* root = buildAhoTree();

    rep(i, 0, m-1){
        if(match(root, texts[i].first, texts[i].second)) cout << "YES\n";
        else cout << "NO\n";
    }
}

int main(){
    #ifdef VPAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(10);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}