import java.util.ArrayDeque; import java.util.Scanner; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int N = sc.nextInt(); ArrayDeque deque = new ArrayDeque<>(); while(N --> 0) { if (sc.nextInt() == 0) deque.addLast(sc.next()); else deque.addFirst(sc.next()); } System.out.println(deque.stream().collect(Collectors.joining())); } } }