java HashMap
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
HashMap<String, Integer> map = new HashMap<>();
map.put("3", 3);
map.put("4", 4);
map.put("5", 5);
map.put("6", 6);
map.put("7", 7);
map.put("8", 8);
map.put("9", 9);
map.put("10", 10);
map.put("J", 11);
map.put("Q", 12);
map.put("K", 13);
map.put("A", 14);
map.put("2", 15);
map.put("joker", 16);
map.put("JOKER", 17);
String max = "joker JOKER";
while (sc.hasNextLine()) {
String str = sc.nextLine();
if (str.contains(max)) {
System.out.println(max);
continue;
}
String[] arr = str.split("-");
String left = arr[0];
String right = arr[1];
String[] leftArr = left.split(" ");
String[] rightArr = right.split(" ");
int lLen = leftArr.length;
int rlen = rightArr.length;
if (lLen == 4 && rlen != 4) {
System.out.println(left);
continue;
}
if (lLen != 4 && rlen == 4) {
System.out.println(right);
continue;
}
if (lLen != rlen) {
System.out.println("ERROR");
continue;
}
if (map.get(leftArr[0] +"") > map.get(rightArr[0] +"")) {
System.out.println(left);
} else {
System.out.println(right);
}
}
}
}