#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
stack<ll> st;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i=1; i<=n; i++){
ll j; cin >> j;
if(j == 1){
ll a; cin >> a;
st.push(a);
}
else if(j == 2) st.pop();
else{
if(st.empty()) cout << "Empty!" << '\n';
else cout << st.top() << '\n';
}
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmxsIG47CnN0YWNrPGxsPiBzdDsKCmludCBtYWluKCl7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKCWNpbiA+PiBuOwoJZm9yKGludCBpPTE7IGk8PW47IGkrKyl7CgkJbGwgajsgY2luID4+IGo7CgkJaWYoaiA9PSAxKXsKCQkJbGwgYTsgY2luID4+IGE7CgkJCXN0LnB1c2goYSk7CgkJfQoJCWVsc2UgaWYoaiA9PSAyKSBzdC5wb3AoKTsKCQllbHNlewoJCQlpZihzdC5lbXB0eSgpKSBjb3V0IDw8ICJFbXB0eSEiIDw8ICdcbic7CgkJCWVsc2UgY291dCA8PCBzdC50b3AoKSA8PCAnXG4nOwoJCX0KCX0KfQ==