• + 0 comments

    if name == 'main':

    N = int(input())
    lst = []
    for i in range(N):
        lst.append(input())
    out = []
    for i in range(len(lst)):
    
    
        command = str(lst[i]).split()
    
        if command[0] == 'insert':
            out.insert(int(command[1]), int(command[2]))
    
        elif command[0] == 'print':
            print(out)
    
        elif command[0] == 'remove' and int(command[1]) in out:
            out.remove(int(command[1]))
    
        elif command[0] == 'append':
            out.append(int(command[1]))
    
        elif command[0] == 'sort':
            out.sort()
    
        elif command[0] == 'pop' and len(out) > 0:
            out.pop()
    
        elif command[0] == 'reverse':
            out.reverse()