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.math.*;
import static java.lang.Character.isDigit;
import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Character.isDigit;

public class Main{
    static String debug(Object...os){
        String s=deepToString(os);
        System.err.println(s);
        return s;
    }
    
    void run(){
        int t=nextInt(),k=nextInt();
        for(int i=0;i<t;i++) {
            BigInteger l=new BigInteger(next()),u=new BigInteger(next()).add(BigInteger.ONE);
            int uu = calc(u,k);
            int ll = calc(l,k);
            int res = uu-ll;
            if(res<0)res+=M;
            System.out.println(res);
        }
    }
    int M = 1000000007;
    long[] pow8;
    private int calc(BigInteger u,int k){//[0,u)
        String s=u.toString();
        int n=s.length();
        int[] a=new int[n];
        for(int i=0;i<n;i++)a[i] = s.charAt(i)-'0';
        int[] nl=new int[10];
        int[] l=new int[10];
        for(int i=0;i<10;i++)for(int j=0;j<i+1;j++)if(j!=4&&j!=7)nl[i]++;
        for(int i=0;i<10;i++)for(int j=0;j<i+1;j++)if(j==4||j==7)l[i]++;
        long[][] dp=new long[n+1][2];// id,same?
        dp[0][1]=1;
        if(pow8==null) {
            pow8=new long[k+1];
            for(int i=0;i<k+1;i++)pow8[i]=i==0?1:pow8[i-1]*8%M;
        }
        long mul=0;
        int cnt=k;
        int luckyInRange=0;
        for(int i=0;i<n;i++){
            // not lucky
            dp[i+1][0] = (dp[i+1][0] + dp[i][0] * 8 + dp[i][1] * (a[i]>0?nl[a[i]-1]:0));
            dp[i+1][1] = (dp[i+1][1] + dp[i][1] * (1 - lucky(a[i])));
            // lucky
            dp[i+1][0] = (dp[i+1][0] + (i-k>=0?dp[i-k][0]:0) * pow8[k] * 2 + (i-k>=0?dp[i-k][1]:1) * mul * 2);
            if(cnt==k) {
                dp[i+1][0] = (dp[i+1][0] + (i-k>=0?dp[i-k][1]:1)*(a[i]>0 ? l[a[i]-1] : 0));
            }
            dp[i+1][0] %= M;
            dp[i+1][1] = (dp[i+1][1] + (i-k>=0?dp[i-k][1]:1) * (cnt==k && (a[i]==4||a[i]==7) ? 1:0)) % M;
            if(luckyInRange==i) {
                mul = (mul*8 + (a[i]>0 ? nl[a[i]-1]:0))%M;
                if(lucky(a[i])==1)luckyInRange = i;
                else luckyInRange = i+1;
                mul -= i-k>=0 ? (a[i-k]>0?nl[a[i-k]-1]:0)*pow8[k]%M : 0;
                if(mul<0)mul+=M;
            }else {
                if(luckyInRange==i-k) {
                    mul = 0;
                    luckyInRange++;
                    while(luckyInRange<=i) {
                        mul=(mul*8+(a[luckyInRange]>0?nl[a[luckyInRange]-1]:0))%M;
                        if(lucky(a[luckyInRange])==1)break;
                        luckyInRange++;
                    }
                    mul = mul*(i-luckyInRange>=0?pow8[i-luckyInRange]:1)%M;
                }else {
                    mul = mul*8%M;
                    mul -= i-k>=0 ? (a[i-k]>0?nl[a[i-k]-1]:0)*pow8[k]%M : 0;
                    if(mul<0)mul+=M;
                }
            }
            cnt = cnt + (1-lucky(a[i])) - (i-k>=0 ? 1-lucky(a[i-k]) : 1);
        }
        return (int)((u.mod(BigInteger.valueOf(M)).intValue() - dp[n][0] + M)%M);
    }
    int lucky(int a) {
        return a==4||a==7?1:0;
    }
    
    int nextInt(){
        try{
            int c=System.in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextInt();
            int res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    long nextLong(){
        try{
            int c=System.in.read();
            if(c==-1) return -1;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return -1;
            }
            if(c=='-') return -nextLong();
            long res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    double nextDouble(){
        return Double.parseDouble(next());
    }
    
    String next(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(Character.isWhitespace(c))
                c=System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    
    String nextLine(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(c=='\r'||c=='\n')
                c=System.in.read();
            do{
                res.append((char)c);
                c=System.in.read();
            }while(c!='\r'&&c!='\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}