Running Steps

Count left-right alternating sequences of one-step and two-step strides where both legs use equal counts and twos are at least as many as ones.

Medium5CombinatoricsMathInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

A coach wants his runners to climb the stadium steps one or two steps at a time, under four rules.

  1. Each leg takes the same number of two step strides.
  2. Each leg takes the same number of one step strides.
  3. The total number of two step strides is no smaller than the total number of one step strides.
  4. The run starts with the left leg.

The legs alternate, and the total number of steps is always even. Rules 1 and 2 force the two legs to cover the same number of steps.

With six steps, each leg covers three, and there are 4 ways. Writing the right leg strides in bold: 2211, 2112, 1221, 1122. With eight steps there is only one way, 2222, because the two step strides cannot be outnumbered by the one step strides.

Given the total number of steps, count the ways to run them that satisfy all four rules.

Input

The first line contains the number of data sets PP (1P100001 \le P \le 10000).

Each of the next PP lines contains a data set number KK and the total number of steps SS, separated by a space. SS is even and 2S1002 \le S \le 100. Every data set is independent and is processed the same way.

Output

Print one line per data set. Each line holds the data set number KK, a single space, and the number of ways to run the steps that satisfy all four rules.