import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); String[] arr = str.split("-"); String[] arr1 = arr[0].split(" "); String[] arr2 = arr[1].split(" "); String str1="34567891JQKA2"; if(arr[0].equals("joker JOKER")||arr[1].equals("joker JOKER")){ System.out.println("joker JOKER"); }else if (arr1.length==arr2.length){ if(str1.indexOf(arr1[0].substring(0,1))>str1.indexOf(arr2[0].substring(0,1))){ System.out.println(arr[0]); }else { System.out.println(arr[1]); } } else if (arr1.length==4) { System.out.println(arr[0]); } else if (arr2.length==4) { System.out.println(arr[1]); }else { System.out.println("ERROR"); } } }