n = int(input())  # 输入操作次数
queue = []  # 队列
for _ in range(n):
    op = input().split()  # 分割操作字符串
    if op[0] == "push":
        queue.append(int(op[1]))  # 加入队尾
    elif op[0] == "pop":
        if not queue:
            print("error")
        else:
            print(queue.pop(0))  # 输出队首(出队)
    elif op[0] == "front":
        if not queue:
            print("error")
        else:
            print(queue[0])  # 输出队首(不出队)