#include #include using namespace std; int main() { string r_b; string r_f; int N; cin >> N; for (int i = 0; i < N; ++i) { int T; string S; cin >> T; cin >> S; if (T == 0) r_b += S; else r_f += S; } string r; for (int i = r_f.length() - 1; i >= 0; --i) r += r_f[i]; r += r_b; cout << r << endl; return 0; }