A=[]
fp =0
bp =0
 
n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1
 
for e in A[bp:fp+1][::-1]:
    print int(e), A=[] A [] fp =0 fp 0 bp =0 bp 0 n=int(raw_input()) n int(raw_input()) int raw_input() raw_input while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1
  n s = raw_input() s raw_input() raw_input if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
     s[0] == 'i' s[0] s 0 'i' A.append(int(s[7:])) A.append A append int(s[7:]) int s[7:] s 7: 7 fp += 1 fp 1 elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
     s[6] == ' ' s[6] s 6 ' ' try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
     except:
            pass
     i = A[::-1].index(int(s[7:])) i A[::-1].index(int(s[7:])) [::-1].index [::-1] A ::-1 -1 index int(s[7:]) int s[7:] s 7: 7 if i!=-1:
                del A[-i-1]
                fp -=1
         i!=-1 i -1 del A[-i-1] A[-i-1] A -i-1 -i i 1 fp -=1 fp 1 elif s[6] == 'F':
        A.pop()
        fp -=1
     s[6] == 'F' s[6] s 6 'F' A.pop() A.pop A pop fp -=1 fp 1 elif s[6] == 'L':
        bp +=1
     s[6] == 'L' s[6] s 6 'L' bp +=1 bp 1 n -=1 n 1 for e in A[bp:fp+1][::-1]:
    print int(e), e A[bp:fp+1][::-1] [bp:fp+1] A bp:fp+1 bp fp+1 fp 1 ::-1 -1 print int(e) int e A=[] [] A n=int(raw_input()) int(raw_input()) n fp -=1 1 fp bp +=1 1 bp bp =0 0 bp i = A[::-1].index(int(s[7:])) A[::-1].index(int(s[7:])) i fp += 1 1 fp fp -=1 1 fp n -=1 1 n fp =0 0 fp s = raw_input() raw_input() s
A=[]
fp =0
bp =0
 
n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1
 
for e in A[bp:fp+1][::-1]:
    print int(e),