func_code_string: #include <bits/stdc++.h>   using namespace std;   long long dp[1001][1001 + 2][2][2];   int n, k, hv = 1002;   char s[1001 + 5], l[1001 + 5], r[1001 + 5];   long long go(int pos, int pv, int ch, int f) {     if (pos == -1) return (long long)f;     long long &ret = dp[pos][pv][ch][f];     if (ch && ret != -1) return ret;     ret = 0LL;     int mx = s[pos] -  0 ;     if (ch) mx = 9;     for (int i = 0; i <= mx; i++) {       bool nw = ((i == 4) || (i == 7));       ret = (ret + go(pos - 1, (nw) ? pos : pv, ch || (i < mx),                       f || (nw && (pv != hv) && (pv - pos) <= k))) %             1000000007LL;     }     return ret;   }   long long solve(char *str) {     strcpy(s, str);     n = strlen(s);     reverse(s, s + n);     return go(n - 1, hv, 0, 0);   }   void DECbyONE() {     int ln = strlen(l);     if (ln == 1) {       l[0]--;       return;     }     for (int i = ln - 1; i >= 0; i--) {       if (l[i] !=  0 ) {         l[i]--;         break;       } else         l[i] =  9 ;     }     strcpy(s, l);     memset(l, 0, sizeof(l));     int i = 0, kk = 0;     while (s[i] ==  0 ) i++;     for (i; i < ln; i++) l[kk++] = s[i];     l[i] =   0 ;   }   int main() {     int t, N, cs = 1, i, j;     ios_base::sync_with_stdio(0), cin.tie(0);     memset(dp, -1, sizeof(dp));     cin >> t >> k;     while (t--) {       cin >> l >> r;       DECbyONE();       long long R = solve(r);       long long L = solve(l);       cout << (R - L + 1000000007LL) % 1000000007LL << endl;     }     return 0;   }   