#include using namespace std; /////////////////////////////////////////// const long long int INF = 1LL<<60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector; using Vi = vector; using P = pair; using PLL = pair; using matrix = vector>; #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define rp(i,N) for(ll i = 0; i < (ll)N; i++) #define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i) templatebool chmax(T &former, const T &b) { if (formerbool chmin(T &former, const T &b) { if (bT sqar(T x){ return x*x; }//sqrt(x)は平方根; #define Sort(v) std::sort(v.begin(), v.end(), std::greater()) //降順でVをソート #define p_queue(v) priority_queue, greater > template inline void princ(T x){cout< inline void print(T x){cout< inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } /////////////////////////////////////////////////////////////////////////////////// /*const ll MAX = 5000001;//10^7が限界 const ll MOD = Mod; //const ll MOD = INT64_MAX; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll digitsum(ll n){ if(n<10) return n; ll ds=0; while(n>0){ ds += n%10; n/=10; } return digitsum(ds); }*/ ll dp[100050][9]; void solve(){ string t; ll d; cin >> t >> d; ll sum=0; ll ques=0; for(auto ch: t){ if(ch=='?'){ ques++; continue; }else{ sum += ch-'0'; } } if(d==0){ if(sum==0) print(1); else print(0); return; } dp[0][0]=1; repi(i,1,ques+1){ rp(j,9){ dp[i][j]+=dp[i-1][j]; rp(k,9){ dp[i][j]+=dp[i-1][k]; } dp[i][j]%=Mod; } } sum%=9; ll tar=d-sum; if(tar<0) tar+=9; tar%=9; print(dp[ques][tar]); return; } int main(){ cin.tie(0);ios::sync_with_stdio(false); std::cout<