from collections import Counter

t = int(input())



def check(n, a, b):
    if n != a * b:
        return False
    if not (len(str(a)) == len(str(b)) and (len(str(b) + str(a)) == len(str(n))) and len(str(a)) == len(str(n)) // 2):
        return False
    if a % 10 == 0 and b % 10 == 0:
        return False
    s = set(str(a) + str(b))
    # test = len(str(b) + str(a))
    if len(s) != len(set(str(n))) or (len(str(b) + str(a)) != len(str(n))):
        return False
    for i in set(str(n)):
        if i not in s:
            return False
        s.remove(i)
    if s:
        return False
    return True

for i in range(t):
    n, a, b = map(int, input().split())
    print("YES" if check(n, a, b) else "NO")