using namespace std;
#include <set>
#include <map>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <utility>
#include <algorithm>
#define pb push_back
#define sz size
#define f first
#define s second
#define II inline
#define ll long long
#define db double
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define all(v) v.begin() , v.end()
#define CC(v) memset((v),0,sizeof((v)))
#define CP(v,w) memcpy((v),(w),sizeof((w)))
#define mp make_pair
#define IN "nums.in"
#define OUT "nums.out"
#define N_MAX 1<<17
typedef vector<int> VI;
typedef pair<int,int> pi;
typedef vector<string> VS;
int x,N,K,M;
int Q[1<<20],A[1<<18],P[N_MAX],V[N_MAX],Nr[N_MAX],S[N_MAX],E[N_MAX];
char buffer[1<<23];
II void read(int &aux)
{
aux = 0;
for(;buffer[K] < '0' || buffer[K] > '9';++K);
for(;buffer[K] >= '0' && buffer[K] <= '9';++K)
aux = aux * 10 + buffer[K] - '0';
}
II void read_string(int k)
{
for(;buffer[K] < '0' || buffer[K] > '9';++K);
S[k] = K;
for(;buffer[K] >= '0' && buffer[K] <= '9';++K);
E[k] = K-1;
Nr[k] = E[k] - S[k] + 1;
}
II void scan()
{
freopen(IN,"r",stdin);
freopen(OUT,"w",stdout);
scanf("%d",&N);
fread(buffer,1,1<<23,stdin);
fclose(stdin);
}
II void sort(int st,int dr,int p,int next)
{
if(st >= dr)
{
V[ Q[st] ] = ++next;
P[next] = Q[st];
return;
}
if(S[ Q[st] ] + p > E[ Q[st] ])
{
++next;
P[next] = Q[st];
FOR(i,st,dr)
V[ Q[i] ] = next;
return;
}
int mij = dr-st+1;
vector< pair<char,int> > B(mij+2);
FOR(i,1,mij)
B[i] = mp(buffer[ S[ Q[st+i-1] ] + p ],Q[st+i-1]);
sort(B.begin()+1,B.begin()+mij+1);
int last = 1;
FOR(i,2,mij)
{
if(B[i].f == B[i-1].f)
continue;
FOR(j,last,i-1)
Q[++Q[0]] = B[j].s;
sort(dr+1,Q[0],p+1,next);
Q[0] -= i-last;
next += i-last;
last = i;
}
FOR(j,last,mij)
Q[++Q[0]] = B[j].s;
sort(dr+1,Q[0],p+1,next);
Q[0] -= mij-last;
}
II void compute()
{
int next(0),tip,Cmax(0);
VI A[N_MAX];
FOR(i,1,N)
{
read(tip);
if(!tip)
{
read(tip);
continue;
}
read_string(++M);
A[ Nr[M] ].pb(M);
Cmax = max(Cmax,Nr[M]);
}
FOR(i,1,Cmax)
{
Q[0] = 0;
for(VI::iterator it=A[i].begin();it != A[i].end();++it)
Q[++Q[0]] = *it;
if(Q[0])
sort(1,Q[0],0,next);
next += Q[0];
}
}
II int querry(int nod,int st,int dr)
{
if(st==dr)
return st;
int ln = (nod<<1);
int rn = ln+1;
int mij = (st+dr) >> 1;
if(A[ln] < x)
{
x -= A[ln];
return querry(rn,mij+1,dr);
}
return querry(ln,st,mij);
}
II void update(int nod,int st,int dr)
{
if(st==dr)
{
++A[nod];
return;
}
int ln = (nod<<1);
int rn = ln+1;
int mij = (st+dr) >> 1;
if(x <= mij)
update(ln,st,mij);
else
update(rn,mij+1,dr);
A[nod] = A[ln] + A[rn];
}
II void solve()
{
int tip,next(0);
K = 0;
FOR(i,1,N)
{
read(tip);
if(!tip)
{
read(x);
int poz = P[ querry(1,1,N) ];
FOR(j,S[poz],E[poz])
printf("%c",buffer[j]);
printf("\n");
continue;
}
for(;buffer[K] < '0' || buffer[K] > '9';++K);
for(;buffer[K] >= '0' && buffer[K] <= '9';++K);
x = V[++next];
update(1,1,N);
}
}
int main()
{
scan();
compute();
solve();
// printf("Time : %d ms\n",clock() );
return 0;
}