from collections import deque
n = int(input())
data = deque(list(input() for _ in range(n)))

ans = deque([])
co = 0

for i in data:
    if i[6] == ' ':
        if i[0] == 'i':
            ans.insert(0, i[7:])
            co += 1
        else:
            try:
                ans.remove(i[7:])
                co -= 1
            except:
                pass
    else:
        if i[6] == 'F':
            del ans[0]
            co -= 1
        else:
            del ans[-1]
            co -= 1

for i in range(0, co-1):
    print(ans[i], end=' ')
print(ans[co-1]) from collections import deque n = int(input()) n int(input()) int input() input data = deque(list(input() for _ in range(n))) data deque(list(input() for _ in range(n))) deque list(input() for _ in range(n)) list input() input ans = deque([]) ans deque([]) deque [] co = 0 co 0 for i in data:
    if i[6] == ' ':
        if i[0] == 'i':
            ans.insert(0, i[7:])
            co += 1
        else:
            try:
                ans.remove(i[7:])
                co -= 1
            except:
                pass
    else:
        if i[6] == 'F':
            del ans[0]
            co -= 1
        else:
            del ans[-1]
            co -= 1 i data if i[6] == ' ':
        if i[0] == 'i':
            ans.insert(0, i[7:])
            co += 1
        else:
            try:
                ans.remove(i[7:])
                co -= 1
            except:
                pass
    else:
        if i[6] == 'F':
            del ans[0]
            co -= 1
        else:
            del ans[-1]
            co -= 1 i[6] == ' ' i[6] i 6 ' ' if i[0] == 'i':
            ans.insert(0, i[7:])
            co += 1
        else:
            try:
                ans.remove(i[7:])
                co -= 1
            except:
                pass
     i[0] == 'i' i[0] i 0 'i' ans.insert(0, i[7:]) ans.insert ans insert 0 i[7:] i 7: 7 co += 1 co 1 try:
                ans.remove(i[7:])
                co -= 1
            except:
                pass
     except:
                pass
     ans.remove(i[7:]) ans.remove ans remove i[7:] i 7: 7 co -= 1 co 1 if i[6] == 'F':
            del ans[0]
            co -= 1
        else:
            del ans[-1]
            co -= 1 i[6] == 'F' i[6] i 6 'F' del ans[0] ans[0] ans 0 co -= 1 co 1 del ans[-1] ans[-1] ans -1 co -= 1 co 1 for i in range(0, co-1):
    print(ans[i], end=' ') i range(0, co-1) range 0 co-1 co 1 print(ans[i], end=' ') print ans[i] ans i end=' ' end ' ' print(ans[co-1]) print ans[co-1] ans co-1 co 1 co += 1 1 co co -= 1 1 co data = deque(list(input() for _ in range(n))) deque(list(input() for _ in range(n))) data co = 0 0 co ans = deque([]) deque([]) ans co -= 1 1 co n = int(input()) int(input()) n co -= 1 1 co
from collections import deque
n = int(input())
data = deque(list(input() for _ in range(n)))

ans = deque([])
co = 0

for i in data:
    if i[6] == ' ':
        if i[0] == 'i':
            ans.insert(0, i[7:])
            co += 1
        else:
            try:
                ans.remove(i[7:])
                co -= 1
            except:
                pass
    else:
        if i[6] == 'F':
            del ans[0]
            co -= 1
        else:
            del ans[-1]
            co -= 1

for i in range(0, co-1):
    print(ans[i], end=' ')
print(ans[co-1])
