for i in range(int(input(""))): x, y = input("").split(" ") if x.endswith("17") or y.endswith("17"): print("NO") elif (x.endswith("7") and y.endswith("11")) or (x.endswith("11") and y.endswith("7")): print("YES") else: print("NO")