// BEGIN CUT HERE
// END CUT HERE
#line 5 "SumProduct.cpp"
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL mod = 1e9 + 7;
template <typename T> T expo(T b, T e, const T &m) {if(e <= 1) return e==0?1: b;\
return (e&1) == 0?expo((b*b)%m, e>>1, m): (b*expo((b*b)%m, e>>1, m))%m; }
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
const int MAXN = 500;
vector<LL> poly[10];
LL fact[MAXN], ifact[MAXN];
void preprocess() {
fact[0] = (ifact[0] = 1);
for(int i = 1; i < MAXN; i++) {
fact[i] = (fact[i-1]*i)%mod;
}
ifact[MAXN-1] = modinv(fact[MAXN-1], mod); ifact[0] = 1;
for(LL i = MAXN-2; i > 0; i--){
ifact[i] = (ifact[i+1]*(i+1))%mod;
}
assert((fact[2]*ifact[2])%mod == 1);
}
LL nCr(int n, int r) {
return (fact[n] * ((ifact[n-r] * ifact[r])%mod)) % mod;
}
vector<LL> Mul(const vector<LL> &A, const vector<LL> &B) {
vector<LL> res(A.size() + B.size());
for(int i = 0; i < A.size(); i++) {
for(int j = 0; j < B.size(); j++) {
res[i + j] += A[i] * B[j] % mod;
if(res[i + j] >= mod) res[i + j] -= mod;
}
}
return res;
}
class SumProduct {
public:
int findSum(vector <int> amount, int blank1, int blank2) {
preprocess();
LL m = (expo(10ll, (LL)blank1, mod) - 1 + mod) % mod;
m = (m * ((expo(10ll, (LL)blank2, mod) - 1 + mod) % mod)) % mod;
m = m * modinv(9ll, mod) % mod;
m = m * modinv(9ll, mod) % mod;
cerr << "Mul = " << m << endl;
LL ans = 0;
for(LL d1 = 1; d1 < 10; d1++) {
if(amount[d1] == 0) continue;
for(LL d2 = 1; d2 < 10; d2++) {
if(amount[d2] == 0) continue;
amount[d1]--;
amount[d2]--;
if(amount[d1] >= 0 && amount[d2] >= 0) {
LL temp = m;
// if(d1 == d2) temp = temp * modinv(2ll, mod) % mod;
for(LL dgt = 0; dgt < 10; dgt++) {
poly[dgt].resize(amount[dgt] + 1);
for(LL i = 0; i < poly[dgt].size(); i++) {
poly[dgt][i] = ifact[i];
}
}
vector<LL> res = Mul(poly[0], poly[1]);
for(int dgt = 2; dgt < 10; dgt++) {
res = Mul(res, poly[dgt]);
res.resize(blank1 + blank2 + 2);
}
temp = temp * res[blank1 + blank2 - 2] % mod;
temp = temp * (d1 * d2) % mod;
temp = temp * fact[blank1 + blank2 - 2] % mod;
ans += temp;
ans %= mod;
}
amount[d1]++;
amount[d2]++;
}
}
return ans;
}
};