Triangle tower
题号:NC200599
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A triangle tower consist of floors. The ith floor has 2i-1 small triangles, each small triangle has an integer in it.The jth small triangle of ith floor has an integer f(i,j), f(i,j) can be calculated by such rules:

· f(i,1)=f(i,2*i-1)=1 for all i [1,n]
· f(i,j)=f(i-1,j-1) if j is even for all i [1,n].
· f(i,j)=f(i,j-1)+f(i,j+1) if j is odd for all i [1,n].




Hery wants you to help him to caculate .

输入描述:

The first line is an integer T, the test cases.
For each test cases, input 2 integers n,m.

输出描述:

For each n,m, ouput  in one line.
示例1

输入

复制
4
1 1
2 1
3 1
3 3

输出

复制
1
1
1
2