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.*;
import static java.lang.Math.*;

public class D implements Runnable {
	final int MN = 1000 + 5;
	final long MOD = 1000000007;
	int k;

	long [][] d;

	long get(char [] num) {
	 	long res = 0;
		int last = -1;
		for (int i = 0; i <= num.length; i++) {
			if (i == 0) {
				int digit = num[0] - '0';
				for (int put = 0; put < digit; put++) {
					int first = put == 4 || put == 7 ? k : 0;
					res = (res + d[num.length - 1][first]) % MOD;	
				}
				continue;
			}
			if (num[i - 1] == '4' || num[i - 1] == '7') {
				if (last != -1 && i - 1 - last <= k) {
					break;
				}
				last = i - 1;
			}
			if (i == num.length) {
				res++;
				break;
			}
			int digit = num[i] - '0';
			for (int put = 0; put < digit; put++) {
				int nlast = last;
				if (put == 4 || put == 7) {
					if (last != -1 && i - last <= k) {
						continue;
					}
					nlast = i;	
				}
				int first = max(nlast - i + k, 0);
				if (nlast == -1) first = 0;
				res = (res + d[num.length - i - 1][first]) % MOD;
			}
		}

		res = (total(num) - res + MOD) % MOD;

		return res;	
	}

	long total(char [] num) {
		long res = 0;
		for (int i = 0; i < num.length; i++) {
			res = (res * 10 + (num[i] - '0')) % MOD;
		}
		return res;	
	}	

	boolean check(char [] num) {
		int last = -1;
		for (int i = 0; i < num.length; i++) {
			if (num[i] == '4' || num[i] == '7') {
				if (last != -1 && i - last <= k) return true;
				last = i;
			}
		}
		return false;
	}

	void solve() throws Exception {
		int T = nextInt();
		k = nextInt();

		d = new long[MN + 1][MN + 1];
		for (int first = 0; first <= MN; first++) {
			d[0][first] = 1;
		}

		for (int len = 1; len < MN; len++) {
			for (int first = 0; first <= MN; first++) {
				if (first > 0) {
					d[len][first] = (8 * d[len - 1][first - 1]) % MOD;
				} else {
					d[len][0] = (8 * d[len - 1][0] + 2 * d[len - 1][k]) % MOD;
				}
			}
		}

		for (int test = 0; test < T; test++) {
			char [] L = nextToken().toCharArray();
			char [] R = nextToken().toCharArray();
			long ans = (get(R) - get(L) + MOD) % MOD;
			if (check(L)) ans = (ans + 1) % MOD;
			out.println(ans);
		}	
	}

	public static void main(String[] args) {
		new Thread(new D()).start();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintWriter out;
	
	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}
}