func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const int M = 1000000007;   int t;   int n, k;   string s;   int dp[1001][1002][2];   int get(int it, int d, bool complete, bool zero) {     if (it == 0) return complete;     if (zero && dp[it][d][complete] != -1) return dp[it][d][complete];     long long ret = 0;     int to = zero ? 9 : s[n - it] -  0 ;     for (int i = 0; i <= to; i++) {       bool nxtZero = zero || (i < to);       bool nxtComplete = complete || ((i == 4 || i == 7) && (d <= k));       int nxtD = min((i == 4 || i == 7) ? 1 : d + 1, 1001);       ret += get(it - 1, nxtD, nxtComplete, nxtZero);     }     ret %= M;     if (zero) dp[it][d][complete] = ret;     return ret;   }   bool correct() {     int prev = -1;     for (int i = 0, _n = (n); i < _n; ++i)       if (s[i] ==  4  || s[i] ==  7 ) {         if (prev != -1 && i - prev <= k) return true;         prev = i;       }     return false;   }   void solution() {     cin >> t >> k;     memset((dp), (-1), sizeof((dp)));     while (t--) {       cin >> s, n = (int)((s).size());       int ret = get(n, 1001, 0, 0);       ret -= correct();       cin >> s, n = (int)((s).size());       ret = get(n, 1001, 0, 0) - ret;       if (ret >= M) ret %= M;       if (ret < 0) ret += M;       cout << ret << endl;     }   }   int main() {     solution();     return 0;   }   