b = b * 10 + (a % 10)
#include<bits/stdc++.h>
using namespace std;
typedef struct student{
int num;
int score;
struct student *next;
}stu;
void add(stu **head,stu *p)
{
stu *mov=*head;
if(*head==NULL)
{
*head=p;
p->next=NULL;
}
else
{
while(mov->next!=NULL)
{
mov=mov->next;
}
mov->next=p;
p->next=NULL;
}
}
void fre(stu **head)
{
stu *qb=*head;
while(*head!=NULL)
{
*head=(*head->next);
free(qb)
qb=NULL;
}
}
int main()
{
stu *head,*p;
scanf("%d",&n);
for(int i=1;i<n;i++)
{
p=(stu*)malloc(sizeof(stu));
scanf("%d%d",&p->num,&p->score);
add(&head,p);
}
}
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef struct student{
int x;
struct student *next;
}stu;
int y,n,j,k,l;
void add(stu **head,int x1,stu* p)
{
stu *mov=*head;
while(mov->x!=x1&&mov->next!=0)
{
mov=mov->next;
if(mov->next==0)
{
mov->next=p;
p->next=0;
return;
}
}
p->next=mov->next;
mov->next=p;
}
void seach(stu**head,int y)
{
stu *mov=*head;
while(mov->next!=0&&mov->x!=y)
{
mov=mov->next;
}if(mov->next==0)
{
cout<<'0'<<endl;
return;
}
if(mov->x==y)
{
mov=mov->next;
cout<<mov->x<<endl;
return;
}
}
void delet(stu **head,int y)
{
stu *mov=*head,*i;
while(mov->x!=y&&mov->next!=0){
mov=mov->next;
}
if(mov->next==0)
return;
i=mov->next;
mov->next=i->next;
free(i);
i=0;
}
int main()
{
stu q,*head,*m[N],*p;
q.x=1;
head=&q;
q.next=0;
m[0]=head;
int o=1;
cin>>n;
for(int i=0;i<n;i++){
cin>>j;
if(j==1){
cin>>k>>l;
p=(stu*)malloc(sizeof(stu));
p->x=l;
p->next=0;
m[o++]=p;
add(&head,k,p);
}
if(j==2)
{
cin>>k;
seach(&head,k);
}
if(j==3){
cin>>k;
delet(&head,k);
}
}
return 0;
}