n=int(input())
ls1=[]
while n:
    ls2=input().split(' ')
    if len(ls2)>1:
        ls1.append(int(ls2[1]))
    if len(ls2)==1:
        if ls1==[]:
            print('error')
        elif ls2[0]=='pop':
            print(ls1.pop(0))
        elif ls2[0]=='front':
            print(ls1[0])
    n-=1