from collections import deque
l=deque()
for _ in range(input()):
    a=raw_input().split()
    c=a[0][-4]
    if c=="i":   l.popleft()
    elif c=="L": l.pop()
    elif c=="s": l.appendleft(a[1])
    else:
        try:     l.remove(a[1])
        except:  pass

print " ".join(l) from collections import deque l=deque() l deque() deque for _ in range(input()):
    a=raw_input().split()
    c=a[0][-4]
    if c=="i":   l.popleft()
    elif c=="L": l.pop()
    elif c=="s": l.appendleft(a[1])
    else:
        try:     l.remove(a[1])
        except:  pass _ range(input()) range input() input a=raw_input().split() a raw_input().split() ().split () raw_input split c=a[0][-4] c a[0][-4] [0] a 0 -4 if c=="i":   l.popleft()
    elif c=="L": l.pop()
    elif c=="s": l.appendleft(a[1])
    else:
        try:     l.remove(a[1])
        except:  pass c=="i" c "i" elif c=="L": l.pop()
     c=="L" c "L" elif c=="s": l.appendleft(a[1])
     c=="s" c "s" try:     l.remove(a[1])
        except:  pass excep print " ".join(l) " ".join " " join l a=raw_input().split() raw_input().split() a c=a[0][-4] a[0][-4] c l=deque() deque() l
from collections import deque
l=deque()
for _ in range(input()):
    a=raw_input().split()
    c=a[0][-4]
    if c=="i":   l.popleft()
    elif c=="L": l.pop()
    elif c=="s": l.appendleft(a[1])
    else:
        try:     l.remove(a[1])
        except:  pass

print " ".join(l)