#include <bits/stdc++.h>
using namespace std;
ifstream in("nums.in");
ofstream out("nums.out");
const int lim=1e5+4;
const int z5=1e5;
struct node
{
int ways;
int ok[10];
}nuls;
vector<node> v[lim];
int tree[4*lim];
int cnt[lim];
int nr[lim];
void update(int nod,int l,int r,int poz)
{
if(l==r)
{
tree[nod]=cnt[l];
return ;
}
int med=(l+r)/2;
if(poz<=med) update(2*nod,l,med,poz);
else update(2*nod+1,med+1,r,poz);
tree[nod]=tree[2*nod]+tree[2*nod+1];
}
int query(int nod,int l,int r,int &k)
{
if(l==r) return l;
int med=(l+r)/2;
if(tree[2*nod]>=k) return query(2*nod,l,med,k);
k-=tree[2*nod];
return query(2*nod+1,med+1,r,k);
}
string s;
void add(int nod,int n,int c)
{
if(c==n)
{
v[n][nod].ways++;
return ;
}
int futt=v[n][nod].ok[s[c]-'0'];
if(futt==0)
{
v[n][nod].ok[s[c]-'0']=++nr[n];
v[n].push_back(nuls);
futt=nr[n];
}
v[n][nod].ways++;
add(futt,n,c+1);
}
void afis(int nod,int n,int k,int a)
{
if(a==n)
{
out<<'\n';
return ;
}
int ind=0,futt;
while(ind<=9)
{
futt=v[n][nod].ok[ind];
if(futt==0)
{
++ind;
continue;
}
if(v[n][futt].ways<k)
k-=v[n][futt].ways;
else break;
++ind;
}
out<<ind;
afis(futt,n,k,a+1);
}
int main()
{
for(int i=1;i<=z5;++i)
v[i].push_back(nuls);
int n,t,k;
in>>n;
while(n--)
{
in>>t;
if(t==1)
{
in>>s;
add(0,s.size(),0);
cnt[s.size()]++;
update(1,1,z5,s.size());
continue;
}
in>>k;
int c=query(1,1,z5,k);
afis(0,c,k,0);
}
return 0;
}