#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; } reverse(head.begin(),head.end()); cout<