import sys

class quese:
    def __init__(self):
        self.list=[]
    def push(self,x):
        self.list.append(x)
    def pop(self):
        x=self.list.pop(0)
        return x        
    def front(self):
        return self.list[0]
    def size(self):
        return len(self.list)

n=int(input())
quese1=quese()

while n>0:
    str=input()
    if str[0:4]=='push':
        quese1.push(int(str[5:]))
    if str[0:3]=='pop':
        if quese1.size()==0:
            print('error')
        else:
            print(quese1.pop())    
    if str[0:5]=='front':
        if quese1.size()==0:
            print('error')
        else:
            print(quese1.front())    
    n-=1