A.书籍(book)
#include<bits/stdc++.h>
using namespace std;
stack<string> s;
string ss;
int q;
int main() {
freopen("book.in","r",stdin);
freopen("book.out","w",stdout);
cin>>q;
while(q--) {
cin>>ss;
if(ss=="READ") {
cout<<s.top()<<endl;
s.pop();
} else
s.push(ss);
}
return 0;
}