This page is still under construction.

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

Running Steps

Interview

Time limit1sMemory limit256 MB

Summary
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.
Level

Medium5 of 10

Topics
Combinatorics, Math
Solved
No attempts yet

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 (1≤P≤100001 \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 2≤S≤1002 \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.

Examples4

  1. Example 1

    Input
    5
    1 6
    2 8
    3 10
    4 12
    5 60
    
    Expected output
    1 4
    2 1
    3 9
    4 37
    5 40197719157
    
  2. Example 2

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

    Input
    3
    1 4
    2 14
    3 16
    
    Expected output
    1 1
    2 16
    3 101
    
  4. Example 4

    Input
    5
    1 12
    2 12
    3 12
    4 12
    5 12
    
    Expected output
    1 37
    2 37
    3 37
    4 37
    5 37