#include <algorithm>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
#define pb push_back
#define mp make_pair
#define DIM 1000005
#define sc second
#define fs first
ifstream fin ("nums.in");
ofstream fout ("nums.out");
int op[DIM],a[DIM],aint[DIM<<4];
vector <pair <string,int> > v;
int n,m;
void read ()
{
char buff[DIM];
int i,tip;
fin>>n;
for (i=1; i<=n; ++i)
{
fin>>tip;
if (tip)
{
fin>>buff;
v.pb (mp (buff,++m));
}
else
fin>>op[i];
}
}
struct cmp
{
bool operator () (const pair <string,int> &a,const pair <string,int> &b)
{
return a.fs.size ()<b.fs.size () || (a.fs.size ()==b.fs.size () && a.fs<b.fs);
}
};
struct rem
{
bool operator () (const pair <string,int> &a,const pair <string,int> &b)
{
return a.fs==b.fs;
}
};
void update (int nod,int st,int dr,int poz)
{
int mij;
++aint[nod];
if (st<dr)
{
mij=(st+dr)/2;
if (poz<=mij)
update (nod<<1,st,mij,poz);
else
update ((nod<<1)+1,mij+1,dr,poz);
}
}
int query (int nod,int st,int dr,int poz)
{
int mij;
if (st==dr)
return st;
mij=(st+dr)/2;
if (aint[nod<<1]>=poz)
return query (nod<<1,st,mij,poz);
return query ((nod<<1)+1,mij+1,dr,poz-aint[nod<<1]);
}
void solve ()
{
vector <pair <string,int> > :: iterator it;
int i,j;
sort (v.begin (),v.end (),cmp ());
m=unique (v.begin (),v.end (),rem ())-v.begin ();
for (i=1; i<=m; ++i)
a[v[i-1].sc]=i;
for (j=0, i=1; i<=n; ++i)
if (!op[i])
update (1,1,m,a[++j]);
else
fout<<v[query (1,1,m,op[i])-1].fs<<"\n";
}
int main ()
{
read ();
solve ();
return 0;
}