func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1005;   const int MOD = 1000000007;   int t, k, dp[N][N][2];   char l[N], r[N], s[N];   void add(int &a, int b) {     a += b;     if (a >= MOD) a -= MOD;   }   int dfs(int l, int pos, int f, int limit) {     if (l == -1) return f;     if (!limit && dp[l][pos][f] != -1) return dp[l][pos][f];     int up = limit ? (s[l] -  0 ) : 9, ret = 0;     for (int i = 0; i <= up; i++) {       if (i == 4 || i == 7) {         int ff = f;         if (pos != 1001) ff |= ((pos - l) <= k);         add(ret, dfs(l - 1, l, ff, limit && (i == up)));       } else {         add(ret, dfs(l - 1, pos, f, limit && (i == up)));       }     }     if (!limit) dp[l][pos][f] = ret;     return ret;   }   int gao(char *a) {     strcpy(s, a);     reverse(s, s + strlen(s));     return dfs(strlen(a) - 1, 1001, 0, 1);   }   void sub(char *s) {     int len = strlen(s), l = strlen(s) - 1;     while (s[l] ==  0 ) s[l] =  9 , l--;     s[l]--;     if (s[0] ==  0  && len > 1) {       for (int i = 1; i <= len; i++) s[i - 1] = s[i];     }   }   int main() {     memset(dp, -1, sizeof(dp));     cin >> t >> k;     while (t--) {       cin >> l >> r;       sub(l);       cout << ((gao(r) - gao(l)) % MOD + MOD) % MOD << endl;     }     return 0;   }   