import java.util.*; class Human{ String name; int point; String hands; } public class pre { public static void main(String[] args) { Scanner s = new Scanner(System.in); Human a = new Human(); a.name = s.next(); a.point = s.nextInt(); a.hands = s.next(); Human b = new Human(); b.name = s.next(); b.point = s.nextInt(); b.hands = s.next(); if(a.point > b.point){ System.out.println(a.name); } else if(a.point < b.point){ System.out.println(b.name); } else{ System.out.println("-1"); } } }