• + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import re
    
    # Define regex to start with 7-9, followed with 9 digits
    regex = "^[7-9][0-9]{9}$"
    
    n = int(input())
    numbers = []
    
    for i in range(n):
        numbers.append(input())
        
    for number in numbers:
        if re.match(regex, number):
            print("YES")
        else:
            print("NO")