import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

int main(char[][]argv)
{
	auto n = readln.chomp.to!int();
	int[] list;

	for(int i = 0; i < n; ++i){
		string[] str = readln.split;
		string cmd = str[0];

		switch(cmd){
			case "insert":
				int num = str[1].to!int;
				int[] tmp;
				tmp ~= num;
				list = tmp ~ list;
				break;
			case "delete":
				int num = str[1].to!int, j;
				for(j = 0; j < list.length; ++j){
					if(list[j] == num)	break;
				}
				list = list[0..j] ~ list[j+1..$];
				break;
			case "deleteFirst":
				list = list[1..$];
				break;
			case "deleteLast":
				list = list[0..$-1];
				break;
			default:
				break;
		}
		//writeln(i, " : ", list);
	}

	list.map!(to!string).join(" ").writeln;

    return 0;
}