from collections import deque
import sys

def main():
    y = deque()
    input()
    for order in sys.stdin:
        if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
    print(" ".join(y))
    
if __name__ == "__main__":
    main() from collections import deque import sys sys def main():
    y = deque()
    input()
    for order in sys.stdin:
        if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
    print(" ".join(y))
     main y = deque() y deque() deque input() input for order in sys.stdin:
        if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
     order sys.stdin sys stdin if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
     order[0] == "i" order[0] order 0 "i" y.appendleft(order[7:-1]) y.appendleft y appendleft order[7:-1] order 7:-1 7 -1 elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
         order[6] == " " order[6] order 6 " " try:
                y.remove(order[7:-1])
            except:
                pass
         except:
                pass
         y.remove(order[7:-1]) y.remove y remove order[7:-1] order 7:-1 7 -1 elif order[6] == "F":
            y.popleft()
         order[6] == "F" order[6] order 6 "F" y.popleft() y.popleft y popleft y.pop() y.pop y pop print(" ".join(y)) print " ".join(y) " ".join " " join y if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    y = deque()
    input()
    for order in sys.stdin:
        if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
    print(" ".join(y))
     def main():
    y = deque()
    input()
    for order in sys.stdin:
        if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
    print(" ".join(y))
     main
from collections import deque
import sys

def main():
    y = deque()
    input()
    for order in sys.stdin:
        if order[0] == "i":
            y.appendleft(order[7:-1])
        elif order[6] == " ":
            try:
                y.remove(order[7:-1])
            except:
                pass
        elif order[6] == "F":
            y.popleft()
        else:
            y.pop()
    print(" ".join(y))
    
if __name__ == "__main__":
    main()
