#include using namespace std; int main(){ int N; cin>>N; dequed; while(N--){ int t;char s; cin>>t>>s; t?d.push_front(s):d.push_back(s); } for(auto s:d)cout<