count = int(input())
def judge(card1, card2):
get_number1 = card1[0]
get_number2 = card2[0]
# J, Q, K的转换
if get_number1 == "J":
get_number1 == 11
elif get_number1 == "Q":
get_number1 == 12
elif get_number1 == "K":
get_number1 == 13
else: # 其他的都是直接转换成为整数
get_number1 == int(get_number1)
if get_number2 == "J":
get_number2 == 11
elif get_number2 == "Q":
get_number2 == 12
elif get_number2 == "K":
get_number2 == 13
else:
get_number2 == int(get_number2)
# 比较
if get_number1 > get_number2:
return "YES"
else:
return "NO"
for i in range(count):
king_char = input() # 选定王牌花色
card1, card2 = map(str, input().split()) # 输入双方的牌
# 下面进行比较
# 都是王牌花色 / 都不是
if king_char in card1 and king_char in card2:
print(judge(card1, card2))
elif king_char not in card1 and king_char not in card2:
print(judge(card1, card2))
# 一张是,一张不是
else:
if king_char in card1:
print("YES")
else:
print("NO")
0.0分
0 人评分