#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i> N; deque dq; rep(i, 0, N){ int T; char S; cin >> T >> S; if(T == 0) dq.push_back(S); else dq.push_front(S); } for(char &c : dq) cout << c; cout << endl; return 0; }