#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int main() { ios_base::sync_with_stdio(0); cin.tie(0); list s; int n; cin >> n; REP (i, n) { int t; char c; cin >> t >> c; if (t) s.push_front(c); else s.push_back(c); } string ret; for (char c: s) ret += c; cout << ret << endl; return 0; }