On Miu's smart phone, there is a search feature which lets her search for a contact name by typing digits on the keypad where each digit may correspond to any of the characters given below it. For example, to search for TOM, she can type 866 and for MAX she can type 629.
+------+-----+------+
|   1  |  2  |   3  |
|      | ABC |  DEF |
+------+-----+------+
|   4  |  5  |   6  |
|  GHI | JKL |  MNO |
+------+-----+------+
|   7  |  8  |   9  |
| PQRS | TUV | WXYZ |
+------+-----+------+
|      |  0  |      |
+------+-----+------+

Miu typed a random string of digits $S$ on the keypad while playing around, where each digit is between 2 and 9 inclusive. Now she wants to know the number of possible strings which would map to $S$. 
Since this number can be very large, output it modulo 10^9 + 7 (1000000007)

-----Input:-----
- 
The first line of the input consists of a single integer $T$ denoting the number of test cases.
- 
Each test case consists of a string $S$.

-----Output:-----
- For each test case, print a single line containing one integer - the count of all possible strings mod 1,000,000,007

-----Constraints-----
- 
1 <= $T$ <= 10
- 
1 <= $|S|$ <= 105

-----Subtasks-----
Subtask #1 (10 points):
- 1 <= $|S|$ <= 10
Subtask #2 (90 points):
- Original Constraints

-----Sample Input:-----
2

5

72  

-----Sample Output:-----
3

12  

-----EXPLANATION:-----
- 
Example Case 1:

On the key 5, we have the character set JKL.

Hence the possible strings are J,K,L.

Hence the answer is 3 % (1000000007) = 3.  
- 
Example Case 2:
On key 7, we have the character set PQRS.

On key 2, we have the character set ABC.

Hence the possible strings are PA,PB,PC,QA,QB,QC,RA,RB,RC,SA,SB,SC.

Hence the answer is 12 % (1000000007) = 12.

Difficulty: interview

Starter code:

Solutions:
for _ in range(int(input())):
 n=int(input())
 n1=0
 ans=1
 while(n>0):
  d=int(n % 10)
  if(d!=0):
   if(d!=9 and d!=7 and d!=1):
    n1=3
   elif(d==1):
    n1=1
   else:
    n1=4
   ans=(int(ans)*int(n1))% (1000000007)
   n/=10
  else:
   n/=10
 if(ans==1):
  print("0")
 else:
  print(ans %(1000000007))


t = int(input())
for i in range(t):
 l = [0,0,3,3,3,3,3,4,3,4]
 n = int(input())
 s=1
 while(n>0):
  if(l[int(n%10)]!=0):
   s*=l[int(n%10)]
  n/=10
 print(s)


# cook your dish here

n=int(input())
for i in range(n):
 num=int(input())

 mul=1
 while num:
  a=(num%10)
  num//=10
  if a==7 or a==9:
   mul*=4
  else:
   mul*=3
 
 print(mul%1000000007)


# cook your dish here

n=int(input())
for i in range(n):
 num=int(input())
 a=[]
 while num:
  a.append(num%10)
  num//=10
 mul=1
 for j in a:
  if j==7 or j==9:
   mul*=4
  elif j!=0 and j!=1:
   mul*=3
 print(mul%1000000007)


for _ in range(int(input())):
 n=int(input())
 n1=0
 ans=1
 while(n>0):
  d=int(n % 10)
  if(d!=0):
   if(d!=9 and d!=7 and d!=1):
    n1=3
   elif(d==1):
    n1=1
   else:
    n1=4
   ans=(int(ans)*int(n1))% (1000000007)
   n/=10
  else:
   n/=10
 if(ans==1):
  print("0")
 else:
  print(ans %(1000000007))


t = int(input())
for i in range(t):
 l = [1,0,3,3,3,3,3,4,3,4]
 n = int(input())
 s=1
 while(n>0):
  s*=l[int(n%10)]
  n/=10
 print(s)


# cook your dish here


arr=["ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"]
t=int(input())
for i in range(0,t):
 n=str(input())
 
 n=int(n)
 
 p=n
 hi=1
 while p>1:
  j=p%10
  j=int(j)
  if j>1:
   
   hi=(hi*len(arr[j-2]))%1000000007
   
  p=p/10
 
 
 print(hi)
 


# cook your dish here


arr=["ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"]
t=int(input())
for i in range(0,t):
 n=str(input())
 l=len(n)
 n=int(n)
 
 p=n
 hi=1
 while p>1:
  j=p%10
  j=int(j)
  if j>1:
   
   hi=hi*len(arr[j-2])
   
  p=p/10
 
 
 print(hi)
 


# cook your dish here

def count(res):
 sum=0
 for items in result:
  sum=sum+1
 return sum 
 
import itertools
arr=["ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"]
t=int(input())
for i in range(0,t):
 n=str(input())
 l=len(n)
 n=int(n)
 s=""
 p=n
 hi=1
 while p>0:
  j=p%10
  j=int(j)
  if j>1:
   #s=s+arr[j-2]
   #result=itertools.combinations(arr[j-2],1)
   hi=hi*len(arr[j-2])
   
  p=p/10
 #result=itertools.combinations(s,l)
 
 print(hi)
 


# cook your dish here
lst = {2:3,3:3,4:3,5:3,6:3,7:4,8:3,9:4}

for _ in range(int(input())):
 val = list(map(int,input().strip()))
 count = 1
 for i in val:
  count*=lst[int(i)]
 if count != 1:
  print(count%1000000007)
 else:
  print(0)


M = 1000000007
def letterCombinations(s):
 n = len(s)
 digits = list(s)
 if n==0:
  return []
 table = [0,0,3,3,3,3,3,4,3,4]
 
 ans = 1
 for i in range(n):
  ans = (ans* table[int(digits[i])])%M
 print(ans%M)

t = int(input())
while t>0:
 s = input().strip()
 letterCombinations(s)
 
 t-=1

# cook your dish here
d={'2':3,'3':3,'4':3,'5':3,'6':3,'7':4,'8':3,'9':4}
mod=10**9+7
try:
 t=int(input())
 while(t):
  mul=1
  s=int(input())
  s=str(s)
  s=sorted(s)
  for i in s:
   mul=mul*(d[i])
  print(mul%mod)
  t=t-1
except EOFError:
 pass


# cook your dish here
d={'2':3,'3':3,'4':3,'5':3,'6':3,'7':4,'8':3,'9':4}
mod=10**9+7
try:
 t=int(input())
 while(t):
  mul=1
  s=int(input())
  s=str(s)
  s=sorted(s)
  for i in s:
   mul=mul*(d[i])
  print(mul%mod)
  t=t-1
except EOFError:
 pass


t = int(input())

for _ in range(t):
 n = input().strip()
 answer = 1
 for x in n:
  if int(x) <= 6 or int(x) == 8:
   answer *= 3
  elif int(x) == 7 or int(x) == 9:
   answer *= 4
 print(answer % 1000000007)


d={2:3,3:3,4:3,5:3,6:3,7:4,8:3,9:4}

t=int(input())

res=[]

for x in range(t):
 st=input()
 mul=1
 for i in st:
  if i.isdigit()==False:
   continue
  digit=int(i)
  if digit>=2 and digit<=9:
   mul=mul*d[int(i)]
   mul=mul%(1000000007)
  else:
   continue
 
 res.append(mul)

for x in res:
 print(x)

d={1:1,2:3,3:3,4:3,5:3,6:3,7:4,8:3,9:4,0:1}
n=int(input())
for i in range(n):
 p=int(input())
 sum=1
 if(p<9):
  print(d[p])
 else:
  r=str(p)
  for j in range(len(r)):
   sum=sum*d[int(r[j])]
  print(sum%1000000007)

# cook your dish here
constant = (10**9)+7
try:
 testCases = int(input().strip())
 for _ in range(testCases):
  total = 1
  ip = list(input().strip())
  for i in ip:
   if i in ['7','9']:
    total *= 4
   else:
    total *= 3
  print(total % constant)
except EOFError:
 pass

# cook your dish here
constant = (10**9)+7
try:
 testCases = int(input().strip())
 for _ in range(testCases):
  total = 1
  ip = list(input().strip())
  for i in ip:
   if i in ['7','9']:
    total *= 4
   else:
    total *= 3
  print(total % constant)
except EOFError:
 pass

from sys import stdin

mod = 1000000007
for _ in range(int(stdin.readline())):
 s = stdin.readline().strip()
 ans = 1
 for ele in s:
  if ele == '7' or ele == '9':
   ans = (ans*4)%mod
  else:
   ans = (ans*3)%mod
 print(ans%mod)


# cook your dish here
t=int(input())
while(t>0):
 n=int(input())
 c=1
 while(n>0):
  m=n%10
  if(m==7 or m==9):
   c*=4
  else:
   c*=3
  n=n//10
 print(c%1000000007)
 t-=1

# cook your dish here

t = int(input())
#d = {"1":1, "2":3, "3":3, "4":3, "5":3, "6":3, "7":4, "8":3, "9":4, "0":1}
for rep in range(t):
 p = 1
 s = input()
 l = list(s)
 for i in l:
  if i == "7" or i == "9":
   p = (p * 4) % 1000000007
  elif i in ["2","3","4","5","6","8"]:
   p = (p * 3) % 1000000007
 print(p)