#include <bits/stdc++.h> using namespace std; class Queue { private: queue<long long> q; public: int push(long long x) { q.push(x); return q.size(); } long long pop() { if(q.empty()) return -1; long long ret = q.front(); q.pop(); return ret; } long long clear() { long long ret = 0; while(!q.empty()) ret ^= q.front(),q.pop(); return ret; } }; int main() { int q; cin >> q; Queue queue; string s; getline(cin, s); while (q--) { getline(cin, s); if (s.find("PUSH") != string::npos) { int idx = s.find(" "); cout << queue.push(atoi(s.substr(idx + 1).c_str())) << endl; } else if ("POP" == s) { cout << queue.pop() << endl; } else { cout << queue.clear() << endl; } } return 0; }