#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

// Sum of digits in base 10 is a multiple of D
ll generate(ll depth, ll sum, bool tight, ll D, const string& digits, vector<vector<vector<ll>>>& memo) {
    if (depth == digits.size()) {
        return sum % D == 0;
    }
    if (memo[depth][sum][tight] != -1) {
        return memo[depth][sum][tight];
    }
    ll limSup = tight ? (digits[depth] - '0') : 9;
    ll ans = 0;
    for (ll d = 0; d <= limSup; d++) {
        bool newTight = tight && d == limSup;
        ans = (ans + generate(depth + 1, (sum + d) % D, newTight, D, digits, memo)) % MOD;
    }
    return memo[depth][sum][tight] = ans;
}

int main() {
    string s;
    cin >> s;
    ll D;
    cin >> D;
    ll n = s.size();
    vector<vector<vector<ll>>> memo(n, vector<vector<ll>>(D, vector<ll>(2, -1)));
    ll ans = generate(0, 0, true, D, s, memo);
    cout << (ans - 1 + MOD) % MOD << "\n"; // don't count 0
}
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 998244353;
ll n, k, fact[MAXN], inv[MAXN], res[MAXN];

ll C(ll x, ll y) {
    if (x > y) return 0;
    return fact[y] * inv[x] % MOD * inv[y - x] % MOD;
}

int main() {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i < MAXN; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = Pow(fact[i], MOD - 2, MOD);
    }
    scanf("%lld%lld", &k, &n);
    for (ll i = 2; i <= 2 * k; i++) {
        ll ans = 0;
        for (ll j = 0; j <= i / 2; j++) {
            if (j & 1) {
                ans = (ans - C(n - j - j, k + n - j * 2 - 1) * C(j, i / 2) % MOD + MOD) % MOD;
            } else {
                ans = (ans + C(n - j - j, k + n - j * 2 - 1) * C(j, i / 2) % MOD) % MOD;
            }
        }
        res[i] = ans;
        if (i <= k + 1) printf("%lld\n", res[i]);
        else printf("%lld\n", res[k + k + 2 - i]);
    }
    return 0;
}

