#include #include #include #include #include #include #include #include using namespace std; int main() { int n; string s = ""; cin >> n; for (int i = 0; i < n; i++){ char c; int t; cin >> t >> c; if (t == 0) s = s+c; else s = c + s; } cout << s << endl; }