from collections import deque
import sys

stack = deque()

def linked_list(stack,command,x=None):

    if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop() 


N = int(input())
#lst = [l.split() for l in sys.stdin.readlines()]
#print(lst)
for i in range(N):

    #print(i)
    input_command = input()


    if input_command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif input_command == "deleteLast":#右端の要素を削除
        stack.pop() 

    else:
        command,x = input_command.split()
        if command == "insert":#stackの左端にxを追加
            stack.appendleft(x)

        elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass

print(" ".join(map(str,stack))) from collections import deque import sys sys stack = deque() stack deque() deque def linked_list(stack,command,x=None):

    if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop()  linked_list if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop()  command == "insert" command "insert" stack.appendleft(x) stack.appendleft stack appendleft x elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

     command == "delete" command "delete" try:
            stack.remove(x)
        except:
            pass

     except:
            pass

     stack.remove(x) stack.remove stack remove x elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

     command == "deleteFirst" command "deleteFirst" stack.popleft() stack.popleft stack popleft elif command == "deleteLast":#右端の要素を削除
        stack.pop()  command == "deleteLast" command "deleteLast" stack.pop() stack.pop stack pop stack stack command command x=None x None N = int(input()) N int(input()) int input() input for i in range(N):

    #print(i)
    input_command = input()


    if input_command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif input_command == "deleteLast":#右端の要素を削除
        stack.pop() 

    else:
        command,x = input_command.split()
        if command == "insert":#stackの左端にxを追加
            stack.appendleft(x)

        elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass i range(N) range N input_command = input() input_command input() input if input_command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif input_command == "deleteLast":#右端の要素を削除
        stack.pop() 

    else:
        command,x = input_command.split()
        if command == "insert":#stackの左端にxを追加
            stack.appendleft(x)

        elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass input_command == "deleteFirst" input_command "deleteFirst" stack.popleft() stack.popleft stack popleft elif input_command == "deleteLast":#右端の要素を削除
        stack.pop() 

     input_command == "deleteLast" input_command "deleteLast" stack.pop() stack.pop stack pop command,x = input_command.split() command input_command.split() input_command.split input_command split x if command == "insert":#stackの左端にxを追加
            stack.appendleft(x)

        elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass command == "insert" command "insert" stack.appendleft(x) stack.appendleft stack appendleft x elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass command == "delete" command "delete" try:
                stack.remove(x)
            except:
                pass except:
                pass stack.remove(x) stack.remove stack remove x print(" ".join(map(str,stack))) print " ".join(map(str,stack)) " ".join " " join map(str,stack) map str stack stack = deque() deque() stack def linked_list(stack,command,x=None):

    if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop()  def linked_list(stack,command,x=None):

    if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop()  linked_list command,x = input_command.split() input_command.split() command x = input_command.split() input_command.split() x N = int(input()) int(input()) N input_command = input() input() input_command
from collections import deque
import sys

stack = deque()

def linked_list(stack,command,x=None):

    if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop() 


N = int(input())
#lst = [l.split() for l in sys.stdin.readlines()]
#print(lst)
for i in range(N):

    #print(i)
    input_command = input()


    if input_command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif input_command == "deleteLast":#右端の要素を削除
        stack.pop() 

    else:
        command,x = input_command.split()
        if command == "insert":#stackの左端にxを追加
            stack.appendleft(x)

        elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass

print(" ".join(map(str,stack)))
