#include using namespace std; int main() { int n; cin >> n; string ans, head; for (int i = 0; i < n; i++) { int t; char s; cin >> t >> s; if (t) head += s; else ans += s; } reverse(head.begin(), head.end()); cout << head + ans << "\n"; return 0; }