#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int32_t n; cin >> n; string sf, sr; for (auto i = 0; i < n; ++i) { int32_t t; char c; cin >> t >> c; if (t == 0) sf.push_back(c); else sr.push_back(c); } reverse(sr.begin(), sr.end()); cout << sr << sf << endl; return 0; }