while (line = readline()) {
// 通过数组的索引确定牌的大小顺序
const compare = ['3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A', '2']
// 得到两副牌
const arr = line.split("-")
let [x, y] = [arr[0], arr[1]]
if ((x.indexOf('j') !== -1) || (y.indexOf('j') !== -1)) {
// 如果有副牌中有大小王,则直接输出大小王
console.log("joker JOKER")
} else {
// 将每张牌中间的空格去除,以方便获取牌的个数
// 将牌面 10 换成 T -> 因为当类型相同时,需要比较第一个字符确定牌面大小,如果是 10 的话,就会取到 1
let xTemp = x.replace(/10/g, "T").replace(/ /g, "")
let yTemp = y.replace(/10/g, "T").replace(/ /g, "")
// 得到两副牌的个数
let [xTempLen, yTempLen] = [xTemp.length, yTemp.length]
if (xTempLen !== yTempLen) {
// 两副牌个数不相同
if (xTempLen === 4) {
// 第一副牌是炸弹,输出第一副牌
console.log(x)
} else if (yTempLen === 4) {
// 第二副牌是炸弹,输出第二副牌
console.log(y)
} else {
// 两副牌都没炸弹,类型不同,无法比较
console.log("ERROR")
}
} else {
// 两副牌个数相同 -> 类型相同
if (compare.indexOf(xTemp[0]) > compare.indexOf(yTemp[0])) {
// 第一副牌的牌面大
console.log(x)
} else {
console.log(y)
}
}
}
}