#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m;
char op;
while(cin >> n){
stack<int> s;
while(n --){
cin >> op;
if(op == 'P'){
cin >> m;
s.push(m);
} else if(op == 'A'){
if(!s.empty()){
cout << s.top() << endl;
} else {
cout << 'E' << endl;
}
} else if(op == 'O'){
if(!s.empty())s.pop();
}
}
}
return 0;
}

京公网安备 11010502036488号