#include <bits/stdc++.h>
#define gc getchar
#define pc putchar
using namespace std;
/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
*/
/*
two functions for policy based data structure. it is
find_by_order() and order_of_key().
The first returns an iterator to the k-th largest element (counting from zero),
the second returns the number of items in a set that are strictly smaller than our item
*/
#define vi vector<int>
#define si set<int>
#define vs vector<string>
#define pii pair<int,int>
#define vpi vector<pii>
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define mpi map<int,int>
#define i64 long long int
#define endl '\n'
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Rep(i,x,y) for(int i=x;i<=y;i++)
#define eps 1e-8
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt","w", stdout)
#define sz size()
#define dbg(x) printf("yo is %d!\n",x)
#define dbg2(x,y) printf("yo is %d! and %d!\n",x,y)
#define foreach(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define sqr(a) (a) * (a)
#define clr clear()
#define CASE(a) printf("Case %d:\n",a)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
//int dx[] = {0,1,0,-1};
//int dy[] = {1,0,-1,0};
//int dx[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
//int dy[] = { 0, -1, -1, -1, 0, 1, 1, 1 };
//int dxK[] = { -2, -2, -1, 1, 2, 2, 1, -1 };
//int dyK[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
//functions
//i64 gcd(i64 a,i64 b){if(!b)return a;return gcd(b,a%b);}
//inline void fastRead(i64 *a){register char c=0;while(c<33)c=gc();*a=0;while(c>33){*a=*a*10+c-'0';c=gc();}}
//inline void fastWrite(int a){char snum[20];int i=0;do{snum[i++]=a%10+48;a=a/10;}while(a!=0);i=i-1;while(i>=0)pc(snum[i--]);pc('\n');}
//i64 bigmod(i64 num,i64 n){if(!n)return 1;i64 x=(bigmod(num,n/2)*bigmod(num,n/2))%mod;if(n%2)x=(x*num)%mod;return x;}
//i64 modinverse(i64 num){return bigmod(num,mod-2);}
//void combination(int pos,int last){if(pos==k+1){for(int i=1;i<=k;i++)cout << tem[i];cout << endl;return;}
//for(int i=last+1;i<=n-k+pos;i++){tem[pos] = num[i-1];combination(pos+1,i);}}
//i64 power(i64 value, i64 base){i64 result = 1;For(i,base)result *= value;return result;}
//int Set(int N,int pos){return N = (1<<pos);}
//int reset(int N,int pos){return N &= (~(1<<pos));}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//typedef tree< int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > Set;
const int maxnode = 1000005;
const int letters=26;
string str,key;
vector<pair<string, int> > v;
int id;
struct Trie
{
int ch[maxnode][letters];
int val[maxnode];
int f[maxnode];
int ss;
void init()
{
ss=1;
mem(ch,0);
mem(val,25);
mem(f,0);
}
void insert(string s)
{
int u=0;
For(i,s.sz)
{
int c=s[i]-'a';
if(!ch[u][c])
ch[u][c]=ss++;;
u=ch[u][c];
}
val[u] = min(val[u],id);
}
void build_fail()
{
queue<int>q;
int i;
For(i,26)
{
if(ch[0][i])
q.push(ch[0][i]);
}
int r,u,v;
while(!q.empty())
{
r=q.front();
q.pop();
For(c,26)
{
u=ch[r][c];
if(!u)
continue;
q.push(u);
v=f[r];
while(v&&ch[v][c]==0)
v=f[v];
f[u]=ch[v][c];
}
}
}
bool search(string s)
{
int j=0;
For(i,s.sz)
{
int c=s[i]-'a';
while(j&&ch[j][c]==0)
j=f[j];
j=ch[j][c];
int temp=j;
while(temp)
{
if(val[temp]<=id)
return true;
temp=f[temp];
}
}
return false;
}
}ac;
int main()
{
int q;
cin >> q;
ac.init();
Rep(i,1,q)
{
int n;
cin >> n;
cin >> str;
if(n==0)
{
id = i;
ac.insert(str);
}
else
{
v.pb(mp(str,i));
}
}
ac.build_fail();
For(i,v.sz)
{
id = v[i].ss;
str = v[i].ff;
if(ac.search(str))
puts("YES");
else
puts("NO");
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgoKI2RlZmluZSBnYyBnZXRjaGFyCiNkZWZpbmUgcGMgcHV0Y2hhcgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8qI2luY2x1ZGUgPGV4dC9wYl9kcy90cmVlX3BvbGljeS5ocHA+CiNpbmNsdWRlIDxleHQvcGJfZHMvZGV0YWlsL3N0YW5kYXJkX3BvbGljaWVzLmhwcD4KI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgoKdXNpbmcgbmFtZXNwYWNlIF9fZ251X3BiZHM7CiovCgovKgogICAgICAgIHR3byBmdW5jdGlvbnMgZm9yIHBvbGljeSBiYXNlZCBkYXRhIHN0cnVjdHVyZS4gaXQgaXMKCiAgICAgICAgICAgICAgICBmaW5kX2J5X29yZGVyKCkgYW5kIG9yZGVyX29mX2tleSgpLgoKICAgICAgICBUaGUgZmlyc3QgcmV0dXJucyBhbiBpdGVyYXRvciB0byB0aGUgay10aCBsYXJnZXN0IGVsZW1lbnQgKGNvdW50aW5nIGZyb20gemVybyksCiAgICAgICAgdGhlIHNlY29uZCByZXR1cm5zIHRoZSBudW1iZXIgb2YgaXRlbXMgaW4gYSBzZXQgdGhhdCBhcmUgc3RyaWN0bHkgc21hbGxlciB0aGFuIG91ciBpdGVtCgoqLwoKI2RlZmluZSB2aSB2ZWN0b3I8aW50PgojZGVmaW5lIHNpIHNldDxpbnQ+CiNkZWZpbmUgdnMgdmVjdG9yPHN0cmluZz4KI2RlZmluZSBwaWkgcGFpcjxpbnQsaW50PgojZGVmaW5lIHZwaSB2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ZXR0ZXJzXTsKICAgIGludCB2YWxbbWF4bm9kZV07CiAgICBpbnQgZlttYXhub2RlXTsKICAgIGludCBzczsKICAgIHZvaWQgaW5pdCgpCgl7CgkJc3M9MTsKCQltZW0oY2gsMCk7CgkJbWVtKHZhbCwyNSk7CgkJbWVtKGYsMCk7Cgl9CgogICAgdm9pZCBpbnNlcnQoc3RyaW5nIHMpCiAgICB7CiAgICAgICAgaW50IHU9MDsKICAgICAgICBGb3IoaSxzLnN6KQogICAgICAgIHsKICAgICAgICAgICAgaW50IGM9c1tpXS0nYSc7CiAgICAgICAgICAgIGlmKCFjaFt1XVtjXSkKICAgICAgICAgICAgICAgIGNoW3VdW2NdPXNzKys7OwogICAgICAgICAgICB1PWNoW3VdW2NdOwogICAgICAgIH0KICAgICAgICB2YWxbdV0gPSBtaW4odmFsW3VdLGlkKTsKICAgIH0KICAgIHZvaWQgYnVpbGRfZmFpbCgpCiAgICB7CiAgICAgICAgcXVldWU8aW50PnE7CiAgICAgICAgaW50IGk7CiAgICAgICAgRm9yKGksMjYpCiAgICAgICAgewogICAgICAgICAgICBpZihjaFswXVtpXSkKICAgICAgICAgICAgICAgIHEucHVzaChjaFswXVtpXSk7CiAgICAgICAgfQogICAgICAgIGludCByLHUsdjsKICAgICAgICB3aGlsZSghcS5lbXB0eSgpKQogICAgICAgIHsKICAgICAgICAgICAgcj1xLmZyb250KCk7CiAgICAgICAgICAgIHEucG9wKCk7CiAgICAgICAgICAgIEZvcihjLDI2KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB1PWNoW3JdW2NdOwogICAgICAgICAgICAgICAgaWYoIXUpCiAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICBxLnB1c2godSk7CiAgICAgICAgICAgICAgICB2PWZbcl07CgogICAgICAgICAgICAgICAgd2hpbGUodiYmY2hbdl1bY109PTApCiAgICAgICAgICAgICAgICAgICAgdj1mW3ZdOwogICAgICAgICAgICAgICAgZlt1XT1jaFt2XVtjXTsKCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBib29sIHNlYXJjaChzdHJpbmcgcykKICAgIHsKICAgICAgICBpbnQgaj0wOwogICAgICAgIEZvcihpLHMuc3opCiAgICAgICAgewogICAgICAgICAgICBpbnQgYz1zW2ldLSdhJzsKICAgICAgICAgICAgd2hpbGUoaiYmY2hbal1bY109PTApCiAgICAgICAgICAgICAgICBqPWZbal07CiAgICAgICAgICAgIGo9Y2hbal1bY107CiAgICAgICAgICAgIGludCB0ZW1wPWo7CiAgICAgICAgICAgIHdoaWxlKHRlbXApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKHZhbFt0ZW1wXTw9aWQpCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICB0ZW1wPWZbdGVtcF07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQp9YWM7CgppbnQgbWFpbigpCnsKCWludCBxOwoJY2luID4+IHE7CglhYy5pbml0KCk7CgoJUmVwKGksMSxxKQogICAgewoJCWludCBuOwoJCWNpbiA+PiBuOwoKCQljaW4gPj4gc3RyOwoKICAgICAgICBpZihuPT0wKQogICAgICAgIHsKICAgICAgICAgICAgaWQgPSBpOwogICAgICAgICAgICBhYy5pbnNlcnQoc3RyKTsKICAgICAgICB9CgkJZWxzZQogICAgICAgIHsKICAgICAgICAgICAgdi5wYihtcChzdHIsaSkpOwogICAgICAgIH0KICAgIH0KICAgIGFjLmJ1aWxkX2ZhaWwoKTsKICAgIEZvcihpLHYuc3opCiAgICB7CiAgICAgICAgaWQgPSB2W2ldLnNzOwogICAgICAgIHN0ciA9IHZbaV0uZmY7CiAgICAgICAgaWYoYWMuc2VhcmNoKHN0cikpCiAgICAgICAgICAgIHB1dHMoIllFUyIpOwogICAgICAgIGVsc2UKICAgICAgICAgICAgcHV0cygiTk8iKTsKICAgIH0KfQoK