#include <stdio.h>#include <malloc.h>#include <string.h>struct node{  struct node *next;  struct node *prev;  int key;};typedef struct node * NodePointer;struct node nil;int flag=0;NodePointer f; void insert(int);void delete(int);void deleteFirst(void);void deleteLast(void);void init(){    nil.next=NULL;    nil.prev=NULL;} int main(){    NodePointer p;    int i, n, key;    char com[12];    scanf("%d", &n);    init();    for ( i = 0; i < n; i++ ){        scanf("%s",com);        if(strlen(com)>6){            if(com[6]=='F'){                deleteFirst();            } else if ( com[6] == 'L' ) {                deleteLast();            }         }else{            scanf("%d",&key);            if(com[0]=='i'){                insert(key);            }else{            delete(key);       }    }    }  for(p=nil.next;p->next!=NULL;p=p->next){    printf("%d ",p->key);  }  printf("%dn",p->key);  return 0;}  void insert(int key){    NodePointer temp;    flag++;    temp=(NodePointer)malloc(sizeof(struct node));    if(flag==1)f=temp;    temp->key=key;    temp->next=nil.next;    temp->prev=&nil;    nil.next=temp;} void delete(int key){    NodePointer p, q;    p=nil.next;    q=&nil;    while(p!=NULL&&p->key!=key){        q = p;           /*This q have prevew of p*/    p = p->next;    }    if(p==f){        deleteLast();    }else if(p!=NULL){        q->next=p->next;        p->next->prev=p;        free(p);    }} void deleteFirst(){    NodePointer p, q;    p=nil.next;    q=&nil;    q->next=p->next;    p->next->prev=q;    if(p==f)f=q;    free(p);} void deleteLast(){    NodePointer p, q;    p=nil.next;    q=&nil;    while(p->next!=NULL){        q = p;           /*This q have prevew of p*/    p = p->next;    }    f=q;    q->next=NULL;    free(p);}