#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b,i;
  list<int>a;
  cin>>n;
  string s;
  list<int>::iterator it;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i')a.push_front(b);
      else{
        it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  it=a.begin();
  for(i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}
