#include <bits/stdc++.h>
using namespace std;
stack<int> stk;
int main(){
int n;
while (cin >> n){
while (n --){
string op;
cin >> op;
if (op == "P"){
int x;
cin >> x;
stk.push(x);
}
else if (op == "O"){
if (!stk.empty()) stk.pop();
}
else{
if (stk.empty()) puts("E");
else printf("%d\n", stk.top());
}
}
}
return 0;
}



京公网安备 11010502036488号