• + 0 comments
    #import regex package --> iterate through input, use regex "^[789]\d{9}$" to match to input using findall --> finall returns a list, if list size is not 0 then a match has been found, and print according result
    
    import re
    
    for i in range(int(input())):
        num = input()
        x = re.findall("^[789]\d{9}$", num)
        
        if len(x) > 0:
            print("YES")
        else:
            print("NO")