import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a) import collections collections a=collections.deque() a collections.deque() collections.deque collections deque for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop() _ range(int(input())) range int(input()) int input() input b=input() b input() input if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop() b[0]=='i' b[0] b 0 'i' elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
     b[6]==' ' b[6] b 6 ' ' try:a.remove(b[7:])
        except:pass
     except:pass
     elif len(b)>10:a.popleft()
     len(b)>10 len(b) len b 10 elif len(b)>6:a.p len(b)>6 len(b) len b 6 print(*a) print *a a a=collections.deque() collections.deque() a b=input() input() b
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)
