#include #include #include #include #include #include #include #include #include using namespace std; typedef long long int lli; #define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++) #define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--) struct CS { int x; string s; }; int main(void) { string ans = ""; int N; cin >> N; CS *a; a = new CS[N]; for (int i = 0; i < N; i++) { cin >> a[i].x >> a[i].s; if (a[i].x == 0) { ans = ans + a[i].s; } else { ans = a[i].s + ans; } } cout << ans << endl; return 0; }