#include<bits/stdc++.h>
using namespace std;
int main(){
 string str;
  list<int> li;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      li.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=li.begin(),l=li.end();it!=l;++it){
    if(*it == x){
      li.erase(it);
      break;
    }
      }
    }else if(str == "deleteFirst") li.pop_front();
    else li.pop_back();
  }
  for(it=li.begin(),l=--li.end();it!=l;++it){
  cout << *it << " ";
	}
  cout << *it << endl;
}

