include[HTML_REMOVED]
include[HTML_REMOVED]
const int N=100000010;
int a[N],tt=-1;//队尾
using namespace std;
int main()
{
int n;
cin>>n;
int hh=0;//队首
while(n–)
{
string s;
cin>>s;
if(s=="push")//插入
{
int t;
cin>>t;
a[++tt]=t;
}
else if(s=="pop")//弹出
{
hh++;
}else if(s=="empty")//空,如果按照栈写会错
{
if(hh<=tt)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
else {
cout<<a[hh]<<endl;//查询
}
}
}