from collections import deque

def process_command(dll, commands):
    # line_count = 1
    for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64)


if __name__ == '__main__':
    # ??????????????\???
    commands = []
    num = int(input())
    commands = [input() for i in range(num)]

    # ??????
    dll = deque()
    process_command(dll, commands)

    # ???????????????
    print('{0}'.format(' '.join(map(str, dll)))) from collections import deque def process_command(dll, commands):
    # line_count = 1
    for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64) process_command for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64) cmd commands try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
         except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
         cmd, num_str = cmd.split() cmd cmd.split() cmd.split cmd split num_str if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64) cmd == 'insert' cmd 'insert' dll.appendleft(int(num_str)) dll.appendleft dll appendleft int(num_str) int num_str elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
         cmd == 'delete' cmd 'delete' if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
         int(num_str) in dll int(num_str) int num_str dll temp = [] temp [] result = dll.popleft() result dll.popleft() dll.popleft dll popleft while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                 result != int(num_str) result int(num_str) int num_str temp.append(result) temp.append temp append result result = dll.popleft() result dll.popleft() dll.popleft dll popleft temp = temp[::-1] temp temp[::-1] temp ::-1 -1 dll.extendleft(temp) dll.extendleft dll extendleft temp elif cmd == 'deleteFirst':
            dll.popleft()
         cmd == 'deleteFirst' cmd 'deleteFirst' dll.popleft() dll.popleft dll popleft elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64) cmd == 'deleteLast' cmd 'deleteLast' dll.pop() dll.pop dll pop dll dll commands commands if __name__ == '__main__':
    # ??????????????\???
    commands = []
    num = int(input())
    commands = [input() for i in range(num)]

    # ??????
    dll = deque()
    process_command(dll, commands)

    # ???????????????
    print('{0}'.format(' '.join(map(str, dll)))) __name__ == '__main__' __name__ '__main__' commands = [] commands [] num = int(input()) num int(input()) int input() input input() for i in range(num) for i in range(num) i range(num) range num for i in range(num) input() input commands = [input() for i in range(num)] commands [input() for i in range(num)] dll = deque() dll deque() deque process_command(dll, commands) process_command dll commands print('{0}'.format(' '.join(map(str, dll)))) print '{0}'.format(' '.join(map(str, dll))) '{0}'.format '{0}' format ' '.join(map(str, dll)) ' '.join ' ' join map(str, dll) map str dll dll = deque() deque() dll commands = [] [] commands commands = [input() for i in range(num)] [input() for i in range(num)] commands def process_command(dll, commands):
    # line_count = 1
    for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64) def process_command(dll, commands):
    # line_count = 1
    for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64) process_command num = int(input()) int(input()) num
from collections import deque

def process_command(dll, commands):
    # line_count = 1
    for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64)


if __name__ == '__main__':
    # ??????????????\???
    commands = []
    num = int(input())
    commands = [input() for i in range(num)]

    # ??????
    dll = deque()
    process_command(dll, commands)

    # ???????????????
    print('{0}'.format(' '.join(map(str, dll))))