class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string result = ""; for(int i = 0; i < n; i++) { string[] inputStr = Console.ReadLine().Split(' '); result = StringCreation(int.Parse(inputStr[0]), inputStr[1], result); } Console.WriteLine(result); } private static string StringCreation(int onoff, string str, string result) { if (onoff == 0) { return result + str; } else { return str + result; } } }