import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayDeque deq = new ArrayDeque<>(); for (int i = 0; i < n; i++) { if (sc.nextInt() == 0) { deq.addLast(sc.next().charAt(0)); } else { deq.addFirst(sc.next().charAt(0)); } } StringBuilder sb = new StringBuilder(); while (deq.size() > 0) { sb.append(deq.poll()); } System.out.println(sb); } }