Problem:
Score : 700 points

Problem Statement

Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.
For each i=2,3,...,2K, find the following value modulo 998244353:

The number of combinations of N sides shown by the dice such that the sum of no two different sides is i.

Note that the dice are NOT distinguishable, that is, two combinations are considered different when there exists an integer k such that the number of dice showing k is different in those two.

Constraints

1 \leq K \leq 2000

2 \leq N \leq 2000

K and N are integers.

Input

Input is given from Standard Input in the following format:

K N

Output

Print 2K-1 integers. The t-th of them (1\leq t\leq 2K-1) should be the answer for i=t+1.

Sample Input 1

3 3

Sample Output 1

7
7
4
7
7

For i=2, the combinations (1,2,2),(1,2,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.

For i=3, the combinations (1,1,1),(1,1,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.

For i=4, the combinations (1,1,1),(1,1,2),(2,3,3),(3,3,3) satisfy the condition, so the answer is 4.

Sample Input 2

4 5

Sample Output 2

36
36
20
20
20
36
36

Sample Input 3

6 1000

Sample Output 3

149393349
149393349
668669001
668669001
4000002
4000002
4000002
668669001
668669001
149393349
149393349

Solution in Rust (1.15.1) (judge verdict: Time Limit Exceeded)

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b == 0 {
        *x = 1;
        *y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    }
    return d;
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x: i64 = 0;
    let mut y: i64 = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

struct ModFactorial {
    fact: Vec<i64>,
}

// returns n! under mod m
impl ModFactorial {
    fn new(n: i64, m: i64) -> ModFactorial {
        let mut fact = vec![1; n as usize + 1];
        for i in 2..fact.len() {
            fact[i] = (i as i64 * fact[i - 1]) % m;
        }
        ModFactorial { fact: fact }
    }
}

// returns bin[i] = nCi under mod m
struct ModBinominal {
    bin: Vec<i64>,
}

impl ModBinominal {
    fn new(n: i64, m: i64, mod_factorial: &ModFactorial) -> ModBinominal {
        let mut bin = vec![1; n as usize + 1];
        if n == 0 {
            return ModBinominal { bin: bin };
        }
        for i in 1..n + 1 {
            let a2 = mod_factorial.fact[i as usize] % m;
            let a3 = mod_factorial.fact[(n - i) as usize] % m;
            bin[i as usize] = mod_factorial.fact[n as usize] * mod_inverse(a2 * a3 % m, m) % m;
        }
        ModBinominal { bin: bin }
    }
}

fn h_comb(n: i64, r: i64, bins: &Vec<ModBinominal>) -> i64 {
    // nHr = n + r - 1Cr
    bins[(n + r - 1) as usize].bin[r as usize]
}

fn main() {
    let v = read_vec::<i64>();
    let big_int = 998244353i64;
    let (k, n) = (v[0], v[1]);
    let fact = ModFactorial::new(k + n + 1, big_int);
    let mut bins = Vec::with_capacity((k + n + 1) as usize);
    for i in 0..k + n + 1 {
        bins.push(ModBinominal::new(i, big_int, &fact));
    }
    let total = h_comb(k, n, &bins);

    let mut answers = Vec::new();

    for i in 2..k + 2 {
        let mut ans = total;
        for j in 1..i / 2 + 1 {
            if n < j * 2 {
                break;
            }
            let mut new_section =
                bins[(i / 2) as usize].bin[j as usize] * h_comb(k, n - 2 * j, &bins);
            new_section %= big_int;
            // Inclusion-exclusion principle
            if j % 2 == 1 {
                ans += big_int - new_section;
            } else {
                ans += new_section;
            }
            ans %= big_int;
        }
        answers.push(ans);
    }
    for &ans in answers.iter() {
        println!("{}", ans);
    }
    for &ans in answers.iter().rev().skip(1) {
        println!("{}", ans);
    }
}