#include <bits/stdc++.
h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
/*
* Complete the 'getMax' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts STRING_ARRAY operations as parameter.
*/
vector<int> getMax(vector<string> operations) {
stack<int> st;
vector<int> v;
for (int i=0;i<[Link]();i++) {
string s = operations[i];
if (s[0] == '1')
{
int x = stoi([Link](1));
if ([Link]() and [Link]() > x)
{
[Link]([Link]());
}
else [Link](x);
}
else if (s[0] == '2') {
[Link]();
}
else if (s[0] == '3') {
v.push_back([Link]());
}
}
return v;
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string n_temp;
getline(cin, n_temp);
int n = stoi(ltrim(rtrim(n_temp)));
vector<string> ops(n);
for (int i = 0; i < n; i++) {
string ops_item;
getline(cin, ops_item);
ops[i] = ops_item;
}
vector<int> res = getMax(ops);
for (size_t i = 0; i < [Link](); i++) {
fout << res[i];
if (i != [Link]() - 1) {
fout << "\n";
}
}
fout << "\n";
[Link]();
return 0;
}
string ltrim(const string &str) {
string s(str);
[Link](
[Link](),
find_if([Link](), [Link](), not1(ptr_fun<int, int>(isspace)))
);
return s;
}
string rtrim(const string &str) {
string s(str);
[Link](
find_if([Link](), [Link](), not1(ptr_fun<int, int>(isspace))).base(),
[Link]()
);
return s;
}