/* -*- coding: utf-8 -*- * * 1026.cc: No.1026 OGAWA's New Keyboard - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ char s[MAX_N * 2 + 4]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); int hp = MAX_N, tp = MAX_N; while (n--) { int t; char w[4]; scanf("%d%s", &t, w); if (t == 0) s[tp++] = w[0]; else s[--hp] = w[0]; } for (int i = hp; i < tp; i++) putchar(s[i]); putchar('\n'); return 0; }