#include<bits/stdc++.h>

using namespace std;
queue <string> q;
int main()
{
	
    string s,name;
    while(cin>>s)
    {
        if(s == "PUSH")
        {
            cin>>name; 
            q.push(name);
        }
        if(s == "POP")
        {
            if(q.empty())
            {
                cout<<"EMPTY"<<endl;
            }
            else
            {
                cout<<q.front()<<endl;
                q.pop();
            }
        }
        if(s == "END")
        {
            break;
        }
    }
    return 0;
}

/**************************************************************
	Problem: 1489
	User: admin
	Language: C++
	Result: Accepted
	Time:17 ms
	Memory:2080 kb
****************************************************************/