from collections import deque

N = int(input())
ans = deque()

while N > 0:
    N -= 1

    tmp = input().split()

    if tmp[0] == "delete":
        # for文だとTLEになる
        # for i in range(len(ans)):
        #     if ans[i] == tmp[1]:
        #         ans.pop(i)
        #         break

        try:
            ans.remove(tmp[1])
        except:
            pass

    elif tmp[0] == "deleteFirst":
        ans.popleft()

    elif tmp[0] == "deleteLast":
        ans.pop()

    else:
        ans.appendleft(tmp[1])

print(*ans) from collections import deque N = int(input()) N int(input()) int input() input ans = deque() ans deque() deque while N > 0:
    N -= 1

    tmp = input().split()

    if tmp[0] == "delete":
        # for文だとTLEになる
        # for i in range(len(ans)):
        #     if ans[i] == tmp[1]:
        #         ans.pop(i)
        #         break

        try:
            ans.remove(tmp[1])
        except:
            pass

    elif tmp[0] == "deleteFirst":
        ans.popleft()

    elif tmp[0] == "deleteLast":
        ans.pop()

    else:
        ans.appendleft(tmp[1]) N > 0 N 0 N -= 1 N 1 tmp = input().split() tmp input().split() ().split () input split if tmp[0] == "delete":
        # for文だとTLEになる
        # for i in range(len(ans)):
        #     if ans[i] == tmp[1]:
        #         ans.pop(i)
        #         break

        try:
            ans.remove(tmp[1])
        except:
            pass

    elif tmp[0] == "deleteFirst":
        ans.popleft()

    elif tmp[0] == "deleteLast":
        ans.pop()

    else:
        ans.appendleft(tmp[1]) tmp[0] == "delete" tmp[0] tmp 0 "delete" try:
            ans.remove(tmp[1])
        except:
            pass

     except:
            pass

     ans.remove(tmp[1]) ans.remove ans remove tmp[1] tmp 1 elif tmp[0] == "deleteFirst":
        ans.popleft()

     tmp[0] == "deleteFirst" tmp[0] tmp 0 "deleteFirst" ans.popleft() ans.popleft ans popleft elif tmp[0] == "deleteLast":
        ans.pop()

     tmp[0] == "deleteLast" tmp[0] tmp 0 "deleteLast" ans.pop() ans.pop ans pop ans.appendleft(tmp[1]) ans.appendleft ans appendleft tmp[1] tmp 1 print(*ans) print *ans ans N -= 1 1 N N = int(input()) int(input()) N tmp = input().split() input().split() tmp ans = deque() deque() ans
from collections import deque

N = int(input())
ans = deque()

while N > 0:
    N -= 1

    tmp = input().split()

    if tmp[0] == "delete":
        # for文だとTLEになる
        # for i in range(len(ans)):
        #     if ans[i] == tmp[1]:
        #         ans.pop(i)
        #         break

        try:
            ans.remove(tmp[1])
        except:
            pass

    elif tmp[0] == "deleteFirst":
        ans.popleft()

    elif tmp[0] == "deleteLast":
        ans.pop()

    else:
        ans.appendleft(tmp[1])

print(*ans)
