if __name__ == '__main__':
N = int(input())
arr = []
for j in range(N):
func = (input().split())
if func[0] == "insert":
arr.insert(int(func[1]),int(func[2]))
elif func[0] == "print":
print(arr)
elif func[0] == "remove":
arr.remove(int(func[1]))
elif func[0] == "append":
arr.append(int(func[1]))
elif func[0] == "sort":
arr.sort()
elif func[0] == "pop":
arr.pop()
elif func[0] == "reverse":
arr.reverse()