from collections import deque

def doubly(n):
    list = deque()
    for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
    print(' '.join(list))

if "__main__" == __name__:
    n = int(input())
    doubly(n)
 from collections import deque def doubly(n):
    list = deque()
    for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
    print(' '.join(list)) doubly list = deque() list deque() deque for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
     i range(n) range n line = input().split() line input().split() ().split () input split p = line[0] p line[0] line 0 while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
         True try:
                key = line[1]
                break
            except IndexError:
                break
         except IndexError:
                break
         break key = line[1] key line[1] line 1 break if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
     p == "insert" p "insert" list.appendleft(key) list.appendleft list appendleft key elif p == "deleteFirst":
            list.popleft()
         p == "deleteFirst" p "deleteFirst" list.popleft() list.popleft list popleft elif p == "deleteLast":
            list.pop()
         p == "deleteLast" p "deleteLast" list.pop() list.pop list pop while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
     True try:
                    list.remove(key)
                    break
                except ValueError:
                    break
     except ValueError:
                    break
     break list.remove(key) list.remove list remove key break print(' '.join(list)) print ' '.join(list) ' '.join ' ' join list n n if "__main__" == __name__:
    n = int(input())
    doubly(n) "__main__" == __name__ "__main__" __name__ n = int(input()) n int(input()) int input() input doubly(n) doubly n def doubly(n):
    list = deque()
    for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
    print(' '.join(list)) def doubly(n):
    list = deque()
    for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
    print(' '.join(list)) doubly n = int(input()) int(input()) n
from collections import deque

def doubly(n):
    list = deque()
    for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
    print(' '.join(list))

if "__main__" == __name__:
    n = int(input())
    doubly(n)

