This page is still under construction.

Parts of this page are still being built. What you see may change.

Polynomial Game

Interview

Time limit1sMemory limit256 MB

Summary
For each test case, compute the coefficient of x^N in the product of (1+x+...+x^i) for i from 1 to k.
Level

Medium4 of 10

Topics
Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

Heehyun and Jugyeong like the polynomial game.

In the polynomial game you are given an integer kk and the polynomial

p(x)=(1+x)(1+x+x2)(1+x+x2+x3)⋯(1+x+⋯+xk−1+xk)p(x) = (1+x)(1+x+x^2)(1+x+x^2+x^3)\cdots(1+x+\cdots+x^{k-1}+x^k)

The first player to say the coefficient of xNx^N in p(x)p(x) wins.

Help Heehyun beat Jugyeong.

Input

The first line contains the number of test cases TT (1≤T≤20001 \le T \le 2000).

Each of the next TT lines contains two integers kk and NN separated by a space (1≤k≤201 \le k \le 20, 0≤N≤k(k+1)/20 \le N \le k(k+1)/2).

Output

For each test case, print the coefficient of xNx^N in p(x)p(x) on its own line.

Examples4

  1. Example 1

    Input
    1
    2 2
    
    Expected output
    2
    
  2. Example 2

    Input
    2
    1 0
    1 1
    
    Expected output
    1
    1
    
  3. Example 3

    Input
    4
    5 0
    5 15
    20 0
    20 210
    
    Expected output
    1
    1
    1
    1
    
  4. Example 4

    Input
    7
    3 0
    3 1
    3 2
    3 3
    3 4
    3 5
    3 6
    
    Expected output
    1
    3
    5
    6
    5
    3
    1