/*按照题目要求分别写了各个独立的调用函数
但是显得有点多此一举
但是显得有点多此一举
string用于输入
使用猫、狗queue,结构体包含编号以及次序
*/
#include<iostream>
#include<cstdio>#include<queue>
#include<string>
using namespace std;
struct animal{
int number;//编号
int order;//次序
animal(){}
animal(int m,int n):number(m),order(n){}//构造函数
};
queue<animal>cat;
queue<animal>dog;
void add_animal(bool flag,int number,int order){
if(flag){
cat.push(animal(number,order));
}
else dog.push(animal(number,order));
}
void pollAll(){
while((!cat.empty())&&(!dog.empty())){
if(cat.front().order>dog.front().order){
printf("dog %d\n",dog.front().number);
dog.pop();
}
else{
printf("cat %d\n",cat.front().number);
cat.pop();
}
}
while(!cat.empty()){
printf("cat %d\n",cat.front().number);
cat.pop();
}
while(!dog.empty()){
printf("dog %d\n",dog.front().number);
dog.pop();
}
}
void pollDog(){
while(!dog.empty()){
printf("dog %d\n",dog.front().number);
dog.pop();
}
}
void pollCat(){
while(!cat.empty()){
printf("cat %d\n",cat.front().number);
cat.pop();
}
}
void isEmpty(){
if(cat.empty()&&dog.empty())printf("yes\n");
else printf("no\n");
}
void isDogEmpty(){
if(dog.empty())printf("yes\n");
else printf("no\n");
}
void isCatEmpty(){
if(cat.empty())printf("yes\n");
else printf("no\n");
}
int main(){
int n,order=1;
string s,type;
int number;
scanf("%d",&n);
for(int i=0;i<n;i++){
cin>>s;
if(s=="add"){
cin>>type;
cin>>number;
if(type=="cat")add_animal(true,number,order++);
else add_animal(false,number,order++);
}
else if(s=="pollAll")pollAll();
else if(s=="pollCat")pollCat();
else if(s=="pollDog")pollDog();
else if(s=="isEmpty")isEmpty();
else if(s=="isCatEmpty")isCatEmpty();
else if(s=="isDogEmpty")isDogEmpty();
}
return 0;
}