import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    command = [LSS() for _ in range(n)]

    que = collections.deque()
    for i in command:
        if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

    print(*que)

if __name__ == '__main__':
    resolve() import sys, collections sys collections input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**10 INF 10**10 10 10 def I(): return int(input()) I def F(): return float(input()) F def SS(): return input() SS int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def LI(): return [int(x) for x in input().split()] LI int(x)-1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x)-1 int(x) int x 1 def LI_(): return [int(x)-1 for x in input().split()] LI_ float(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() float(x) float x def LF(): return [float(x) for x in input().split()] LF def LSS(): return input().split() LSS def resolve():
    n = I()
    command = [LSS() for _ in range(n)]

    que = collections.deque()
    for i in command:
        if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

    print(*que) resolve n = I() n I() I LSS() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LSS() LSS command = [LSS() for _ in range(n)] command [LSS() for _ in range(n)] que = collections.deque() que collections.deque() collections.deque collections deque for i in command:
        if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

     i command if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

     i[0]=='insert' i[0] i 0 'insert' que.appendleft(i[1]) que.appendleft que appendleft i[1] i 1 elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
         i[0]=='delete' i[0] i 0 'delete' if i[1] in que:
                que.remove(i[1])
         i[1] in que i[1] i 1 que que.remove(i[1]) que.remove que remove i[1] i 1 elif i[0]=='deleteFirst':
            que.popleft()
         i[0]=='deleteFirst' i[0] i 0 'deleteFirst' que.popleft() que.popleft que popleft elif i[0]=='deleteLast':
            que.pop()

     i[0]=='deleteLast' i[0] i 0 'deleteLast' que.pop() que.pop que pop print(*que) print *que que if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def LSS(): return input().split() def LSS(): return input().split() LSS def resolve():
    n = I()
    command = [LSS() for _ in range(n)]

    que = collections.deque()
    for i in command:
        if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

    print(*que) def resolve():
    n = I()
    command = [LSS() for _ in range(n)]

    que = collections.deque()
    for i in command:
        if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

    print(*que) resolve def F(): return float(input()) def F(): return float(input()) F def SS(): return input() def SS(): return input() SS def LI_(): return [int(x)-1 for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] LI_ def I(): return int(input()) def I(): return int(input()) I def LI(): return [int(x) for x in input().split()] def LI(): return [int(x) for x in input().split()] LI INF = 10**10 10**10 INF input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def LF(): return [float(x) for x in input().split()] def LF(): return [float(x) for x in input().split()] LF
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    command = [LSS() for _ in range(n)]

    que = collections.deque()
    for i in command:
        if i[0]=='insert':
            que.appendleft(i[1])
        elif i[0]=='delete':
            if i[1] in que:
                que.remove(i[1])
        elif i[0]=='deleteFirst':
            que.popleft()
        elif i[0]=='deleteLast':
            que.pop()

    print(*que)

if __name__ == '__main__':
    resolve()
