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