using System.Collections.Generic; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var c = new HashSet(); var ok = new HashSet(); var w = new string[2 * n]; var p = 0; for (int i = 0; i < n; i++) { string[] line = Console.ReadLine().Trim().Split(' '); var a = line[0]; var b = line[1]; w[p++] = a; w[p++] = b; c.Add(a); if (c.Add(b)) { ok.Add(b); c.Remove(b); } } for (int i = 0; i < 2 * n; i++) if (ok.Contains(w[i])) Console.WriteLine(w[i]); } }