#include using namespace std; int main(){ string fr, ba; int n, t; char c; cin >> n; for(int i = 0; i < n; i++){ cin >> t >> c; if(t & 1)fr += c; else ba += c; } reverse(fr.begin(), fr.end()); cout << fr << ba << endl; }