#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    queue<int>q;
    while(n--)
    {
        string s;
        int a;
        cin>>s;
        if(s=="push")
        {
            cin>>a;
            q.push(a);
        }
        else
        {
            if(!q.empty())
            {
                if(s=="pop")
                {
                     cout<<q.front()<<endl;
                     q.pop();
                }
                if(s=="front") cout<<q.front()<<endl;
            }
            else cout<<"error"<<endl;
        }
    }
    return 0;
}