#include <iostream>using namespace std;const int N = 100010;int stk[N],idx,tt = 0;//从0开始,到0时显示栈空void push(int x){stk[++ tt] = x;}void pop(){--tt;}int empty(){if(tt==0) return 1;else return 0;}int query(){return stk[tt];}int main(){int m;cin >> m;while(m--){string op;cin >> op;if(op == "push"){int x;cin >> x;push(x);}else if(op == "pop"){pop();}else if(op == "empty"){if(empty()) cout << "YES" << endl;else cout << "NO" << endl;}else{cout << query() << endl;}}return 0 ;}
