from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)
 from collections import deque import sys sys n = int(input()) n int(input()) int input() input result = deque() result deque() deque func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop} func {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop} 'insert' 'insert' result.appendleft result appendleft 'delete' 'delete' result.remove result remove 'deleteFirst' 'deleteFirst' result.popleft result popleft 'deleteLast' 'deleteLast' result.pop result pop for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]() line sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines c = line.split() c line.split() line.split line split if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]() len(c) > 1 len(c) len c 1 try:
            func[c[0]](int(c[1]))
        except:
            continue
     except:
            continue
     continue func[c[0]](int(c[1])) [c[0]] func c[0] c 0 int(c[1]) int c[1] c 1 func[c[0]]() [c[0]] func c[0] c 0 print(*result) print *result result c = line.split() line.split() c result = deque() deque() result n = int(input()) int(input()) n func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop} {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop} func
from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)

