#include <iostream>
#include <stack>
using namespace std;
stack <unsigned long long> m;
int main() {
unsigned long long t, n;
cin >> t >> n;
for (int i = 1; i <= t; i++) {
for (int j = 1; j <= n; j++) {
string s;
unsigned long long x;
cin >> s;
if (s == "push") {
cin >> x;
m.push(x);
}
else if (s == "pop" && m.empty()) cout << "Empty" << endl;
else if (s == "pop") m.pop();
else if (s == "query" && m.empty()) cout << "Anguei!" << endl;
else if (s == "query") cout << m.top() << endl;
else if (s == "size") cout << m.size() << endl;
}
}
return 0;
}