#include <iostream> #include <vector> using namespace std; int main(){ int n; string operation; vector<int> stack; cin >> n; for (int i = 0; i < n; i++) { cin >> operation; if (operation == "push") { int x; cin >> x; stack.push_back(x); } else if (operation == "pop") { if (stack.empty()) { cout << "error" << endl; } else { cout << stack.back() << endl; stack.pop_back(); } } else if (operation == "top") { if (stack.empty()) { cout << "error" << endl; } else { cout << stack.back() << endl; } } } return 0; }