Even Grid
Practice
3.8 (4 votes)
Easy
Problem
86% Success 752 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Vivek has 2 identical grid of square boxes, The size of grid is N*M where N denotes the no. of rows and M.

Vivek likes even numbers a lot. So he wants to make a new grid from the blocks of the given grids which contains even no. of blocks . He called this type of grid a Even grid.

To make a Even grid, He can take out any box from the grids irrespective of their position in the grid. He believes in equality as well so he takes out equal no. of boxes from each grid.

Find the no. of ways in which he can select boxes to make a new grid. One way is different from other way if atleast one of the chosen box is different.

As the result could be very large, answer the result in 10 9 +7 modulo.

Input:

The first line contains a integer T which denotes the no. of testcases.
Next T lines contains 2 space separated integers N and M respectively.

Output:

For each test , output a integer in a new line denoting the answer for the test case.

Constraints:

1≤ T ≤ 106
1≤ a,b ≤ 106
1≤ a*b ≤ 106

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
49 votes
Tags:
CombinatoricsModulo InversePermutation CyclesEasyPermutationMathematics
Points:20
3 votes
Tags:
Easy
Editorial

Login to unlock the editorial