SP6732 CT14E - Camels
Description
Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with _t_ humps,representing them as polylines in the plane. Each polyline consists of _n_ vertices withcoordinates (_x_ $ _{1} $ , _y_ $ _{1} $ ), (_x_ $ _{2} $ , _y_ $ _{2} $ ), ..., (_x_ $ _{n} $ , _y_ $ _{n} $ ). The first vertex has a coordinate _x_ $ _{1} $ = 1, the second— _x_ $ _{2} $ = 2, etc. Coordinates _y_ $ _{i} $ might be any, but should satisfy the following conditions:
- there should be _t_ humps precisely, i.e. such indexes _j_ (2 j n - 1), so that _y_ $ _{j - 1} $ < _y_ $ _{j} $ > _y_ $ _{j + 1} $ ,
- there should be precisely _t_ - 1 such indexes _j_ (2 j n - 1), so that _y_ $ _{j - 1} $ > _y_ $ _{j} $ < _y_ $ _{j + 1} $ ,
- no segment of a polyline should be parallel to the _Ox_-axis,
- all _y_ $ _{i} $ are integers between 1 and 4.
For a series of his drawings of camels with _t_ humps Bob wants to buy a notebook, but he doesn'tknow how many pages he will need. Output the amount of different polylines that can be drawn to represent camels with _t_ humps for a given number _n_.
Input Format
The first line of input contains the number of testcases , Ntest.
Each testcase contains a pair of integers _n_ and _t_ (3 n , 1 t ).
Output Format
For each testcase ,output the required amount of camels with _t_ humps.
Explanation/Hint
**Note** In the first sample test sequences of y-coordinates for six camels are: 123421, 123431, 123432, 124321, 134321 and 234321 (each digit corresponds to one value of $y_i$).