#include <stdio.h>
#include<string.h>
#include<malloc.h>
typedef struct Node {
int val;
struct Node* next;
} Node;
//初始化
Node* Init() {
Node* n = (Node*)malloc(sizeof(Node));
n->next = NULL;
return n;
}
void Insert(Node* n, int x, int y) {
Node* new = (Node* )malloc(sizeof(Node));
new->next = NULL;
new->val = y;
while (n->next != NULL) {
if (n->next->val ==x)
break;
else
n = n->next;
}
new->next = n->next;
n->next = new;
}
void Delete(Node* n, int x) {
while (n->next != NULL) {
if (n->next->val == x) {
Node* jump = n->next;
n->next = n->next->next;
free(jump);
break;
} else {
n = n->next;
}
}
}
void Print(Node* n) {
if (n->next == NULL) {
printf("NULL");
return;
}
while (n->next != NULL) {
printf("%d ", n->next->val);
n = n->next;
}
}
int main() {
int num;
while (scanf("%d", &num) != EOF) {
char op[20];
int a, b;
Node* n = Init();
//初始化
for (int i = 0; i < num; i++) {
scanf("%s %d %d", op, &a, &b);
if (strcmp(op, "insert") == 0) {
Insert(n, a, b); //插入
} else if (strcmp(op, "delete") == 0) {
Delete(n, a); //删除
}
}
Print(n); //打印
}
}