//KY180 堆栈的使用
#include<bits/stdc++.h>
#include<cstdio>
#include<stack>
using namespace std;
int main(){
stack<int> s;//栈要定义全局的
int n;
char m;
int o;
while(scanf("%d",&n)!=EOF){
for(int i = 0 ;i<n;++i){
scanf("%c",&m);
if(m == 'P'){
scanf("%d",&o);
s.push(o);
}else if(m == 'A'){
if(!s.empty()){
printf("%d\n",s.top());
}else{
printf("E\n");
}
}else if(m == 'O'){
if(!s.empty()){
s.pop();
}
}
}
}
}

京公网安备 11010502036488号