import java.io.*; import java.util.*; public class game { static Map> map; public static void main(String... args) throws Exception { Scanner s = new Scanner(new File("game.in")); int n; while ((n = s.nextInt()) != 0) { String last = null; map = new HashMap>(); for (int i = 0; i < n; i++) last = s.next(); for (int i = 0; i < n - 1; i++) { String a = s.next(); String b = s.next(); Set l = map.get(a); if (l == null) map.put(a, l = new HashSet()); l.add(b); l = map.get(b); if (l == null) map.put(b, l = new HashSet()); l.add(a); } Set played = new HashSet(); Set loosers = new HashSet(); int round = 1; while (map.size() > 1) { loosers.clear(); played.clear(); System.out.println("Round #" + round++); for (String a: map.keySet()) { if (!played.contains(a)) { if (map.get(a).size() == 1) { String b = map.get(a).iterator().next(); if (!played.contains(b)) { last = b; map.get(a).remove(b); map.get(b).remove(a); played.add(a); played.add(b); loosers.add(a); System.out.println(b + " defeats " + a); } } } } for (String a: map.keySet()) if (!played.contains(a)) { played.add(a); System.out.println(a + " advances with wildcard"); break; } map.keySet().removeAll(loosers); } System.out.println("Winner: " + last); System.out.println(); } } }