#include<stdio.h>
typedef int SType;
#define SSize 200;
int In[200];
int Out[200];
int Step[400];
int count=0;
int pop(SType *s,int top){
if(top==-1){
printf("empty stack\n");
return -1;
}
printf("pop %d\n",s[top]);
return --top;
}
int push(SType *s,int top, SType ch){
s[++top]=ch;
printf("push %d\n",s[top]);
return top;
}
bool Check(int n)
{
SType S[SSize];
SType T[SSize];
for(int i=n-1;i>=0;i--)
push(T,Ttop,Out[i]);
for(int i=0;i<n;i++)
{
push(S,Stop,In[i]);
Step[count++]=0;
while(!S.empty()&&!T.empty()&&S.top()==T.top())
{
Step[count++]=1;
pop(S,Stop);
pop(T,Ttop);
}
}
return Stop
}
int main(){
char s[100];
int Stop=Ttop=-1,n;
while(printf("n=")&&~scanf("%d",&n)){
for(int i=0;i<n;i++)
In[i]=i+1;
for(int i=0;i<n;i++)
scanf("%d",&n);
bool res=Check(n);
res?printf("empty"):printf("NOT empty");
printf("\n");
if(res)
for(int i=0;i<count;i++)
Step[i]?printf("OUT"):printf("IN");
return 0;
}
}