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.util.*;
import java.io.*;

public class Horse {
	 static int MAXL = 1005;
	 static int MOD = 1000000007;
	 
	 int k, tst;
	 String L, R;
	 int[][] dp = new int[MAXL][MAXL];
	 
	 int calc(String max, int dep, int inclusive, int dist)
	 {
		 if(dep == max.length()) {
			 if(inclusive > 0) return 1;
			 else return 0;
		 }
		 
		 int num = max.charAt(dep)-'0';
		 int ans = 0;
		 
		 for(int dig = 0; dig <= num; ++dig) {
			 if(dig == 4 || dig == 7) {
				 if(dist > 0) continue;
				 if(dig == num) {
					 ans += calc(max, dep+1, inclusive, k);
					 ans %= MOD;
				 } else {
					 ans += dp[max.length() - dep - 1][k];
					 ans %= MOD;
				 }
			 } else {
				 int td = dist - 1;
				 if(td < 0) td = 0;
				 if(dig == num) {
					 ans += calc(max, dep+1, inclusive, td);
					 ans %= MOD;
				 } else {
					 ans += dp[max.length() - dep - 1][td];
					 ans %= MOD;
				 }
			 }
		 }
		 return ans;
	 }
	 
	 int calcTot(String max, int inclusive)
	 {
		 int ans = 0;
		 for(int i = 0; i < max.length(); ++i) {
			 ans = (int)((long)ans * 10 % MOD) + max.charAt(i)-'0';
			 ans %= MOD;
		 }
		 if(inclusive==0) ans = (ans + MOD -1) % MOD;
		 return ans;
	 }
	 
	 private void solve() throws IOException
	 {
		 tst = nextInt(); k = nextInt();
		 for(int i = 0; i <= k; ++i)
			 dp[0][i] = 1;
		 for(int i = 1; i < MAXL; ++i) {
			 dp[i][0] = (int)( ((long)8 * dp[i-1][0] % MOD + (long)2 * dp[i-1][k] % MOD) % MOD);
			 for(int j = 1; j <= k; ++j)
				 dp[i][j] = (int)((long)8 * dp[i-1][j-1] % MOD);
		 }
		 
		 while(tst>0) {
			 tst--;
			 L = nextToken(); R = nextToken();
			 int bad = (calc(R, 0, 1, 0) - calc(L, 0, 0, 0) + MOD) % MOD;
			 int tot = (calcTot(R, 1) - calcTot(L, 0) + MOD) % MOD;
			 int ans = (tot - bad + MOD) % MOD;
			 writer.println(ans);
		 }
	 }
	 
	 BufferedReader reader;
	 StringTokenizer tokenizer;
	 PrintWriter writer;
	 
	 public static void main(String[] args) throws IOException
	 {
		 new Horse().run();
	 }
	 
	 public void run() throws IOException
	 {
		 reader = new BufferedReader(new InputStreamReader(System.in));
		 tokenizer = null;
		 writer = new PrintWriter(System.out);
		 solve();
		 
		 reader.close();
		 writer.close();
	 }
	 
	 int nextInt() throws IOException {
         return Integer.parseInt(nextToken());
     }

     long nextLong() throws IOException {
         return Long.parseLong(nextToken());
     }

     double nextDouble() throws IOException {
         return Double.parseDouble(nextToken());
     }

     String nextToken() throws IOException {
         while (tokenizer == null || !tokenizer.hasMoreTokens()) {
             tokenizer = new StringTokenizer(reader.readLine());
         }
         return tokenizer.nextToken();
     }
}