Problem: Petya likes horse racing very much. Horses numbered from l to r take part in the races. Petya wants to evaluate the probability of victory; for some reason, to do that he needs to know the amount of nearly lucky horses' numbers. A nearly lucky number is an integer number that has at least two lucky digits the distance between which does not exceed k. Petya learned from some of his mates from Lviv that lucky digits are digits 4 and 7. The distance between the digits is the absolute difference between their positions in the number of a horse. For example, if k = 2, then numbers 412395497, 404, 4070400000070004007 are nearly lucky and numbers 4, 4123954997, 4007000040070004007 are not.

Petya prepared t intervals [li, ri] and invented number k, common for all of them. Your task is to find how many nearly happy numbers there are in each of these segments. Since the answers can be quite large, output them modulo 1000000007 (109 + 7).

Input

The first line contains two integers t and k (1 ≤ t, k ≤ 1000) — the number of segments and the distance between the numbers correspondingly. Next t lines contain pairs of integers li and ri (1 ≤ l ≤ r ≤ 101000). All numbers are given without the leading zeroes. Numbers in each line are separated by exactly one space character.

Output

Output t lines. In each line print one integer — the answer for the corresponding segment modulo 1000000007 (109 + 7).

Examples

Input

1 2
1 100


Output

4


Input

1 2
70 77


Output

2


Input

2 1
1 20
80 100


Output

0
0

Note

In the first sample, the four nearly lucky numbers are 44, 47, 74, 77.

In the second sample, only 74 and 77 are in the given segment.

Solution (in JAVA):

Solution:
import java.io.*;
import java.lang.Math;
import java.util.Scanner;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class main
{
        public static Scanner in;
        public static PrintStream out;
		
		public static long fnk[][];
		public static long tnk[][];
		
		public static long d10[];
		public static long d8[];
		
		public static long M = 1000000007;
		
		static int K;
		
		public static long _Fnk(int n, int k)
		{
			if (n<2)
			{
				return 0;
			}
			
			return (2*Tnk(n-1, k)+ 8*Fnk(n-1, k) + 2*Pnk(n-1, k, k)) % M;
		}
		
		
		public static long Fnk(int n, int k)
		{
			if (fnk[n][k]==-1)			
			{
				fnk[n][k] = _Fnk(n,k);
			}
			return fnk[n][k];
		}
		
		
		public static long Tnk(int n, int k)
		{
			if (tnk[n][k]==-1)			
			{
				tnk[n][k] = _Tnk(n,k);
			}
			return tnk[n][k];
		}
		
		
		public static long Pnk(int n, int r,int k)
		{
			if (n-r<2)
			{
				return 0;
			}
			
			return D8(r)*Fnk(n-r,k) % M;
		}
		
		public static long _Tnk(int n, int k)
		{
			if (k<1)
			{
				return 0;
			}
			
			if (n<1)
			{
				return 0;
			}
			
			if (n>k)
			{
				return 10*Tnk(n-1, k) % M;
			}
			
			return (2*D(n-1)+8*Tnk(n-1, k-1)) % M;
		}
		
		public static long D(int n)
		{
			if (n==0)
			{
				return 1;
			}
			
			if (d10[n]==-1)
			{
				d10[n] = BigInteger.valueOf(10).modPow(BigInteger.valueOf(n), BigInteger.valueOf(M)).longValue();
			}
			
			return d10[n];
		}
		
		public static long D8(int n)
		{
			if (n==0)
			{
				return 1;
			}
			
			if (d8[n]==-1)
			{
				d8[n] = BigInteger.valueOf(8).modPow(BigInteger.valueOf(n), BigInteger.valueOf(M)).longValue();
			}
			
			return d8[n];
		}
		
		public static long F(String s, int k)
		{	
			int n = s.length();
			
			if (n<2)
			{
				return 0;
			}
			
			long r1,r2=0,r = 0;
			
			int d = Integer.parseInt(String.valueOf(s.charAt(0)));
			
			if (d>0)
			{
				r1 = Fnk(n-1, k) % M;
				if (d>4)
				{
					r2 =  (Tnk(n-1, k) + Pnk(n-1, k, k)) % M;
				}
				
				if (d<5)
				{
					r += d* r1;
				}
				else if (d<8)
				{
					r += (d-1)* r1 + r2;
				}
				else
				{
					r += (d-2)* r1 + 2*r2;
				}
			}
			
			String s2 = s.substring(1);
			
			if ((d==4)||(d==7))
			{
				r += (T(s2, k) + P(s2, k, k)) % M;
			}
			else
			{
				r += F(s2, k) % M;
			}
			
			return r % M;
		}
		
		public static long T(String s, int k)
		{
			if (k<1)
			{
				return 0;
			}
			
			int n = s.length();
			
			
			if (n==0)
			{
				return 0;
			}
			
			
			long r1,r2=0,r = 0;
			
			int d = Integer.parseInt(String.valueOf(s.charAt(0)));
			
			
			if (d>0)
			{
				r1 = Tnk(n-1, k-1) % M;
				if (d>4)
				{
					r2 =  D(n-1);
				}
				
				if (d<5)
				{
					r += d* r1;
				}
				else if (d<8)
				{
					r += (d-1)* r1 + r2;
				}
				else
				{
					r += (d-2)* r1 + 2*r2;
				}
			}
						
			String s2 = s.substring(1);
			
			if ((d==4)||(d==7))
			{
				if (s2.length()==0)
				{
					r+= 1;
				}
				else
				{
					BigInteger b = new BigInteger(s2);
					r += b.add(BigInteger.ONE).mod(BigInteger.valueOf(M)).longValue();
				}
			}
			else
			{
				r += T(s2, k-1);
			}
			
			return r % M;
		}
		
		
		public static long P(String s, int r, int k)
		{
			int n = s.length();

			if (n-r<2)
			{
				return 0;
			}
			
			if (k==0)
			{
				return 0;
			}
			
			if (r==0)
			{
				return F(s,k);
			}
			
			long r1,r2=0,rs = 0;
			
			int d = Integer.parseInt(String.valueOf(s.charAt(0)));
			
			
			if (d>0)
			{
				r1 = Pnk(n-1, r-1, k) % M;
				
				if (d<5)
				{
					rs += d* r1;
				}
				else if (d<8)
				{
					rs += (d-1)* r1 ;
				}
				else
				{
					rs += (d-2)* r1 ;
				}
			}
			
			String s2 = s.substring(1);
			
			if ((d==4)||(d==7))
			{
				rs += 0;
			}
			else
			{
				rs += P(s2, r-1, k);
			}
			
			return rs % M;
		}
       
       
        public static void test()
        {
			String ln;
			do {
				ln = in.nextLine();
			} while (ln.length()==0);
			
			StringTokenizer st = new StringTokenizer(ln);
		
             String l,r;
			 l = st.nextToken();
			 r = st.nextToken();
			 
			 BigInteger bl = new BigInteger(l);
			 
			 long s = (M + F(r, K)  - F(bl.subtract(BigInteger.ONE).toString(), K)) % M;
			 
			 out.println(s);
			 
        }
       
        public static void main(String args[])
        {
                try
                {
                        //in = new Scanner(new File("in.txt"));
                        //out = new PrintStream(new File("out.txt"));                  
                        in = new Scanner(System.in);
                        out = System.out;
                }
                catch (Exception e)
                {
                        return;
                }
               
				int t,i,j;
				
				t = in.nextInt();
				K = in.nextInt();
				
				fnk = new long[1001][];
				tnk = new long[1001][];
				d8 = new long[1001];
				d10 = new long[1001];
				
				for (i=0;i<1001;i++)
				{
					fnk[i] = new long[K+1];
					tnk[i] = new long[K+1];
					
					d8[i] = -1;
					d10[i] = -1;
					
					for (j=0; j<=K; j++)
					{
						fnk[i][j] = -1;
						tnk[i][j] = -1;
					}
				}
				
				for (i=0; i<t; i++)
				{
					test();
				}
              

				//	out.println(T("41883", 3));
                
        }
}