MNTILE - Tiling a WxH Grid With Dominoes

Write a program that takes as input the width, W and height H of the grid and outputs the number of different ways to tile a W-by-H grid with (2x1) dominoes.

tiling 10 by 10 grid with (2x1) dominoes

Score is the length of your source.

Input

The first line is an integer T(1 ≤ T ≤ 276), denoting the number of test cases. Then, T test cases follow.

For each test case, there are two integers W and H(0 ≤ W+H ≤ 22) written in one line, separated by space.

Output

For each test case, output the number of different ways to tile a W-by-H grid with (2x1) dominoes.

Example

Input:
6
1 2
2 3
3 4
4 5
5 6
6 7

Output:
1
3
11
95
1183
31529

Information

All outputs will fit on 64-bit signed integer and less than 1015.

You may try M3TILE, M4TILE, or M5TILE first.

 

See also: Another problem added by Tjandra Satria Gunawan


Added by:Tjandra Satria Gunawan
Date:2012-07-02
Time limit:1s
Source limit:300B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM32-GCC ASM64 MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET
Resource:Generalization of M3TILE, M4TILE/GNY07H, and M5TILE problems.

hide comments
2020-12-17 04:57:15
Why is there a source limit on this?
2020-08-07 03:25:08
Why should there be limit on the source code?
2020-06-10 14:26:16
Can someone send the soltuion for this problem or at least the explanation plzz!!
thanks in advance
2016-07-21 09:48:22
@Tjandra Satria Gunawan Please change the source limit to atleast 500 B

Last edit: 2016-07-21 09:49:18
2016-06-23 07:34:59 erdenebayr_d
source limit 300B ?????
2015-07-11 13:12:53 xxbloodysantaxx
Can you please give me a hint how to start! I have solved M2tile and M3tile .
2015-03-25 11:58:05 Dhawal Harkawat
Id- 13949194, please check, its giving WA.

Ans: The answer will always be integer and non-negative

Last edit: 2015-03-25 15:32:20
2015-03-23 20:16:25 Rishabh Joshi
Getting WA. Using system defined value of pi (M_PI). submission ID is 13935610. Please check and suggest. Thanks.

Ans: wrong logic or formula.

Last edit: 2015-03-25 15:31:21
2013-12-15 13:56:31 its_time_to_code
could you please cheak my code getting WA. Id is 8055908
thanx.


Last edit: 2012-11-15 17:02:55
2013-12-15 13:56:31 Pranay
Could you please check why am i getting WA? (7321966)

Ans: Rounding error.

Last edit: 2012-07-25 11:15:39
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.