class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List list = new List(); for (int i = 0; i < n; i++) { string[] str = Console.ReadLine().Split(' '); list = SetList(list, int.Parse(str[0]), char.Parse(str[1])); } Console.Write(String.Join("", list)); } private static List SetList(List list, int v1, char v2) { if(v1 == 0) { list.Add(v2); } else { list.Insert(0, v2); } return list; } }