#include #include using namespace std; int main() { string r; int N; cin >> N; for (int i = 0; i < N; ++i) { int T; string S; cin >> T; cin >> S; if (T == 0) r += S; else r = S + r; } cout << r << endl; return 0; }