//数组模拟指针 #include

using namespace std;

const int N=100010;

int e[N],idx,head,ne[N];

void intit(){ head=-1; idx=0; }

void insert(int x,int y){//插入元素 int find(int x); int i=find(x); if(i==-1){ e[idx]=y; ne[idx]=head; head = idx; idx++; } else if(ne[i]==-1){ e[idx] = y; ne[idx] = ne[i]; ne[i] = idx; idx++; } else if(e[ne[i]]==x){ e[idx] = y; ne[idx] = ne[i]; ne[i] = idx; idx++; } }

void remove(int x){ int find(int x); int i=find(x); if(e[ne[i]]==x){ ne[i]=ne[ne[i]]; } }

int find(int x){//查找元素; int i; if(e[head]==x||head==-1) return -1; for(i=head;i!=-1;i=ne[i]){ if(ne[i] == -1) return i; if(e[ne[i]]==x) return i; } return 0; }

int main(){ intit(); int m; cin>>m; getchar(); while(m--){ string op; int x,y; cin>>op; if(op=="insert"){ cin>>x>>y; insert(x,y); } if(op=="delete"){ cin>>x; remove(x); } } int flag=0; for(int i=head;i!=-1;i=ne[i]){ cout<<e[i]<<' '; flag=1; } if(!flag) cout<<"NULL"; }