We need to compute number of ways to achieve exactly total of k points in exactly N moves, where each move gives an integer from 0 to k inclusive. Note that the upper bound per move is k, but also obviously you can't get more than k total since you want exactly k. However, the per-move maximum is k, but if you get a number > k it would exceed total; but since each move is bounded by k, it's okay. So each move score is in {0,1,...,k}.
We need number of N-tuples (a1,...,aN) such that each ai ∈ [0,k] and sum_{i=1}^{N} ai = k.
Number of solutions to x1+...+xN = k with 0 ≤ xi ≤ k.
But since k ≤ 19 and N ≤ 19, small numbers. Could use combinatorics: number of ways is coefficient of x^k in (1 + x + ... + x^k)^N. Since k is small, we can compute using stars and bars with inclusion-exclusion (since upper bound is k but that's not restrictive unless N is large? Actually, with upper bound k, if N=1, only one way if you pick k, but also if N > k, some xi must be zero? The condition xi ≤ k is usually not restrictive because k is the total sum; each xi ≤ k automatically, because sum is k, each xi cannot exceed k. Actually, if sum is k, each xi is automatically ≤ k because if one xi > k, sum would exceed k. So the constraint xi ≤ k is redundant given sum = k and xi ≥ 0. Wait: Is it always? Suppose N = 3, k = 2. xi ≤ 2 is automatically satisfied because if any xi=3 would sum to at least 3 >2. So indeed, since sum is exactly k, each xi is at most k. So the condition xi ∈ [0,k] is automatically satisfied for any solution to sum = k with nonnegative integers. Therefore, number of ways is simply number of nonnegative integer solutions to x1+...+xN = k, which is C(N+k-1, N-1) = C(N+k-1, k). That's stars and bars.
But wait, is there any nuance? The points per move can be at most k, but we are restricting that the number of points gained is integer between 0 and k inclusive. As argued, any nonnegative solution automatically respects ≤k because sum = k and each term nonnegative. However, is it possible that a solution has a term > k? For sum = k, if one term > k, then sum would be > k because others are ≥ 0. So indeed impossible. So the condition is redundant.
Thus the number of ways should be C(N+k-1, N-1). But check sample: N=2, k=2 => C(2+2-1, 2-1)=C(3,1)=3. Yes matches.
But let's verify other examples: N=1, k=5 => C(1+5-1,0)=C(5,0)=1. Indeed only one way: score exactly 5 in one move. Good. N=5, k=1 => C(5+1-1,4)=C(5,4)=5. So there are 5 ways: put the 1 point in any of the 5 moves, others zero. That matches intuition.
Thus the answer is simply combination: C(N+k-1, k) or equivalently C(N+k-1, N-1).
But we must be careful: Constraints are small, T up to 100k. We can precompute binomial coefficients up to max N+k-1 ≤ 19+19-1=37, so maximum is 37. That's tiny. We can compute factorials or precompute combos with Pascal's triangle up to 40.
But there is a nuance: The problem statement says "He needed to score k points and he could play at most N moves and at least 1 move. In each move, he could get [0,k] points." Then PowerShell challenged Xenny to find the number of ways in which he could score k points in exactly N moves as per the given rules. So it's exactly N moves.
Thus answer is combinations.
Given that N and k up to 19, we can compute combos directly using combinatorial function.
Edge Cases: maybe N = 0? but constraints say at least 1 move, N >= 1. So fine.
Thus for each test case, output C(N+k-1, N-1) (or C(N+k-1, k)). Ensure integer fits within typical limits (up to C(38,19) ~ 3.5e10? Actually C(38,19) is around 3.5e10, which fits in 64-bit. 64-bit max is 9e18, so fine.
Implementation: Since T up to 100k, we can precompute all binomial coefficients for n up to 38 and k up to 38. Then answer per test case in O(1).
Alternatively compute on the fly using combinatorial formula with small numbers.
But careful: The input sample had 1 test case. So fine.
I'll produce solution.
But wait: Could there be any hidden twist? Let's double-check: "He needed to score k points and he could play at most N moves and at least 1 move." This implies that the total moves he can make is up to N, but the challenge is to find ways to score exactly k points in exactly N moves. So it's exactly N moves. So our solution stands.
Thus answer: combination.
Implementation steps:
- Read T.
- Precompute factorial up to 40 (or Pascal triangle up to 40).
- For each line: read N, k.
- Compute n = N + k - 1, r = k (or N-1). Use comb.
- Print result.
But note: In many languages, we can compute comb using math.comb in Python (since 3.8). But given T large, it's fine. But careful: input size T up to 100k, reading input efficiently.
We'll implement in Python:
import sys
from math import comb
def main():
data = sys.stdin.read().strip().split()
if not data: return
it = iter(data)
T = int(next(it))
out = []
for _ in range(T):
N = int(next(it)); k = int(next(it))
out.append(str(comb(N+k-1, k))) # or N-1
sys.stdout.write("\n".join(out))
if __name__ == "__main__":
main()
But note: math.comb available Python 3.8+, and this should be fast enough for 100k small numbers. However, repeated calls to comb may have some overhead, but acceptable.
Alternatively precompute Pascal triangle: create list C[0..38][0..38] = 0, then fill using C[n][0]=C[n][n]=1, and C[n][k]=C[n-1][k-1]+C[n-1][k]. Then answer = C[N+k-1][k]. That might be faster.
But 100k calls to math.comb is fine. However, I'm not sure about the environment; but typically 100k is fine.
But there's also possibility that the problem originally expects modulo? The output is integer, no modulo stated. So exact integer.
Given constraints, it's small.
Thus final answer: For each test case, print C(N+k-1, N-1).
I'll produce the solution with explanation.
But let's double-check: The sample input: 1, 2 2 => C(3,1)=3. Output 3.
Thus correct.
Therefore final answer.
I'll write the solution in code.
But note: There is nuance: The moves can get [0,k] points. That means each move can get at most k, but if N > 1, some moves could also get more than k? No, the constraint is per move. But as argued, the sum constraint forces each move ≤ k, so it's redundant.
Thus answer.
I will produce final answer with Python code. ```python
import sys
def precompute_binom(max_n):
"""
Returns a 2D list C where C[n][k] = binomial coefficient (n choose k)
for 0 <= n, k <= max_n.
"""
C = [[0] * (max_n + 1) for _ in range(max_n + 1)]
for n in range(max_n + 1):
C[n][0] = 1
C[n][n] = 1
for k in range(1, n):
C[n][k] = C[n-1][k-1] + C[n-1][k]
return C
def main():
data = sys.stdin.read().strip().split()
if not data:
return
it = iter(data)
t = int(next(it))
# maximum possible value of n = N + k - 1 (N,k <= 19)
MAX_NK = 38
C = precompute_binom(MAX_NK)
out_lines = []
for _ in range(t):
N = int(next(it))
k = int(next(it))
n = N + k - 1
r = k # could also use N-1, same value
out_lines.append(str(C[n][r]))
sys.stdout.write("\n".join(out_lines))
if name == "main":
main()