#include using namespace std; int main(){ cin.tie(0),ios::sync_with_stdio(false); int n; cin>>n; string ans,head; for(int i=0;i>t>>s; if(t)head+=s; else ans+=s; } for(auto i=head.rbegin();i!=head.rend();++i)cout<<*i; cout<