#include<iostream>
#include<cstring>
using namespace std;
struct node
{
int g;
node *p;
};
int q;
node *head,*l,*n,*c;
int cz;
int x,y;
int main()
{
cin>>q;
head=new node;
l=head;
n=new node;
n->g=1;
n->p=NULL;
head->p=n;
l=n;
for(int i=1;i<=q;i++)
{
n=head->p;
cin>>cz;
if(cz==1)
{
cin>>x>>y;
while (n->g!=x)
{
n=n->p;
}
c=new node;
c->p=n->p;
n->p=c;
c->g=y;
}
else if(cz==2)
{
cin>>x;
while (n->g!=x)
{
n=n->p;
}
n=n->p;
if(n->p==NULL) cout<<"0"<<endl;
else cout<<n->g<<endl;
}
else if(cz==3)
{
cin>>x;
while (n->g!=x)
{
n=n->p;
}
n=n->p->p;
}
}
return 0;
}
大佬求救,不要题解,要问题所在