#include using namespace std; int32_t main() { int n; cin >> n; deque q; for (int i = 0; i < n; i++) { int t; char c; cin >> t >> c; if (t) { q.push_front(c); } else { q.push_back(c); } } string str(q.begin(), q.end()); cout << str << endl; }