#include<iostream>
#include<cstdlib>
#include<string>
#include<list>
using namespace std;
int main(){
  list<int> l;
  int n,tmp;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){    
    cin>>s;
    if(s=="insert"){  
      cin>>tmp;
      l.push_front(tmp);
    }
    else if(s=="delete"){
      cin>>tmp;
      for(auto t=l.begin();t!=l.end();++t){
	if(*t==tmp){
	  t=l.erase(t);
	  break;
	}
      }
    }
    else if(s=="deleteFirst"){
       l.pop_front();
    }
    else if(s=="deleteLast"){
      l.pop_back();
    }
  }
  for(auto i=l.begin();i!=l.end();){
    cout<<*i;
    i++;
    if(i!=l.end()) {cout<<" ";}
  }    cout<<'\n';

    return 0;
}
