#B3717. Compute Binomial Coefficient Modulo 998244353

    ID: 11376 Type: Default 1000ms 256MiB

Compute Binomial Coefficient Modulo 998244353

Compute Binomial Coefficient Modulo 998244353

Given T queries. For each query, you are given two integers \( n \) and \( m \). Your task is to compute the binomial coefficient \( \binom{n}{m} \) (also written as \( C_n^m \)) modulo \( 998244353 \).

If \( m \) is greater than \( n \) or negative, the result is defined to be 0. The binomial coefficient is defined by:

\[ \binom{n}{m} = \frac{n!}{m!(n-m)!} \]

inputFormat

The first line contains an integer \( T \) representing the number of queries.

Each of the following \( T \) lines contains two integers \( n \) and \( m \) separated by a space.

outputFormat

For each query, output a single line containing \( \binom{n}{m} \) modulo \( 998244353 \).

sample

3
5 2
10 3
0 0
10

120 1

</p>