#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<list>
#include<string>
#include<vector>

using namespace std;

#define LL long long

int main() {
	list<int>ls;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		char c[50];
		scanf("%s",&c);
		if(c[0]=='i'){
			int x;
			std::scanf("%d",&x);
			ls.insert(ls.begin(),x);
		}
		else if(c[6]=='L'){
			ls.pop_back();		
		}
		else if(c[6]=='F'){
			ls.pop_front();		
		}
		else {
			int x;
			std::scanf("%d",&x);
			for(auto i=ls.begin();i!=ls.end();i++){
				if(*i==x){
					ls.erase(i);
					break;
				}
			}
		}
	}

	for(auto i=ls.begin();i!=ls.end();i++){
		if(i!=ls.begin())putchar(' ');
		printf("%d",*i);
	}
	printf("\n");
	return 0;
}

//15:30
