#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIHN6KG8pICgoaW50KW8uc2l6ZSgpKQojZGVmaW5lIGFsbChvKSBvLmJlZ2luKCksIG8uZW5kKCkKI2RlZmluZSByZXAoaSwgYSwgYikgZm9yKGludCBpID0gKGEpOyBpIDw9IChiKTsgaSsrKQojZGVmaW5lIHJlcHIoaSwgYSwgYikgZm9yKGludCBpID0gKGEpOyBpID49IChiKTsgaS0tKQoKdHlwZWRlZiBsb25nIGxvbmcgaW50IGxsOwp0eXBlZGVmIHZlY3RvcjxsbD4gdmxsOwp0eXBlZGVmIHZlY3RvcjxpbnQ+IHZpOwoKY29uc3QgaW50IE1BWCA9IDI2LCBJTkYgPSAxZTc7CnZlY3RvcjxwYWlyPHN0cmluZywgaW50Pj4gcGF0cywgdGV4dHM7CmludCBxLCBuLCBtOwoKaW50IGdldElkeChjaGFyIGMpeyByZXR1cm4gYy0nYSc7IH0KCnN0cnVjdCBub2RlewogICAgbm9kZSogZmFpbDsKICAgIG5vZGUqIGNoaWxkW01BWF07CiAgICBpbnQgdGltZTsKCiAgICBub2RlKCl7CiAgICAgICAgbWVtc2V0KGNoaWxkLCAwLCBzaXplb2YoY2hpbGQpKTsKICAgICAgICB0aW1lID0gSU5GOwogICAgICAgIGZhaWwgPSBOVUxMOwogICAgfQoKICAgIHZvaWQgaW5zZXJ0KHN0cmluZyAmc3RyLCBpbnQgcG9zLCBpbnQgbGVuLCBpbnQgaWQpewogICAgICAgIGlmKHBvcyA9PSBsZW4pewogICAgICAgICAgICB0aW1lID0gbWluKHRpbWUsIGlkKTsKICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgaW50IGlkeCA9IGdldElkeChzdHJbcG9zXSk7CiAgICAgICAgICAgIGlmKCFjaGlsZFtpZHhdKXsKICAgICAgICAgICAgICAgIGNoaWxkW2lkeF0gPSBuZXcgbm9kZSgpOwogICAgICAgICAgICAgICAgY2hpbGRbaWR4XS0+aW5zZXJ0KHN0ciwgcG9zKzEsIGxlbiwgaWQpOwogICAgICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgICAgIGNoaWxkW2lkeF0tPmluc2VydChzdHIsIHBvcysxLCBsZW4sIGlkKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCn07Cgp2b2lkIG1vdmUobm9kZSogJmssIGludCBjKXsKICAgIHdoaWxlKCFrLT5jaGlsZFtjXSkgayA9IGstPmZhaWw7CiAgICBrID0gay0+Y2hpbGRbY107Cn0KCm5vZGUqIGJ1aWxkQWhvVHJlZSgpewogICAgbm9kZSogcm9vdCA9IG5ldyBub2RlKCk7CiAgICByb290LT5mYWlsID0gcm9vdDsKICAgIHJlcChpLCAwLCBuLTEpewogICAgICAgIHJvb3QtPmluc2VydChwYXRzW2ldLmZpcnN0LCAwLCBzeihwYXRzW2ldLmZpcnN0KSwgcGF0c1tpXS5zZWNvbmQpOwogICAgfQoKICAgIHF1ZXVlPG5vZGUqPiBxOwogICAgcmVwKGksIDAsIE1BWC0xKXsKICAgICAgICBpZihyb290LT5jaGlsZFtpXSl7CiAgICAgICAgICAgIHJvb3QtPmNoaWxkW2ldLT5mYWlsID0gcm9vdDsKICAgICAgICAgICAgcS5wdXNoKHJvb3QtPmNoaWxkW2ldKTsKICAgICAgICB9ZWxzZSByb290LT5jaGlsZFtpXSA9IHJvb3Q7CiAgICB9CgogICAgd2hpbGUoIXEuZW1wdHkoKSl7CiAgICAgICAgbm9kZSogY3VyID0gcS5mcm9udCgpOwogICAgICAgIHEucG9wKCk7CgogICAgICAgIHJlcChpLCAwLCBNQVgtMSl7CiAgICAgICAgICAgIGlmKGN1ci0+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