=====Problem Statement=====
Let's dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are valid mobile numbers.

Concept
A valid mobile number is a ten digit number starting with a 7, 8, or 9.

=====Input Format=====
The first line contains an integer N, the number of inputs.
N lines follow, each containing some string.

=====Constraints=====
1≤N≤10
2≤len(Number)≤15

=====Output Format=====
For every string listed, print "YES" if it is a valid mobile number and "NO" if it is not on separate lines. Do not print the quotes.

Difficulty: introductory

Starter code:

# Enter your code here. Read input from STDIN. Print output to STDOUT

Solutions:
# Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input())
for i in range(0,n):
    tmp_str=input()
    len_tmp_str=len(tmp_str)
    if(len_tmp_str!=10):
        ##print "LENGTH PROBLEM"
        print("NO")
    elif(tmp_str[0]!="7" and tmp_str[0]!="8" and tmp_str[0]!="9"):
        ##print "START PROBLEM"        
        print("NO")
    else:
        check=1
        for i in tmp_str:
            if(i>="0" and i<="9"):
                continue
            else:
                check=0
                break
        if(check==1):
            print("YES")
        else:
            ##print "NUMBER PROBLEM"            
            print("NO")


import re

n = int(input().strip())

for _ in range(n):
    tel = input().strip()
    pattern = '^[789][0-9]{9}$'
    print("{}".format("YES" if bool(re.match(pattern, tel)) else "NO"))