3.1 League Of Legends
(RankList for this Question)
Score: 30pts
Time Limit: 2.00 sec
Apocalypse has hit and we have Darksied and Thanos joining forces to take over the world. The only chance humanity has of survival is if the DC and Marvel universe forces join hands to fight together but as we are all aware has been a long-term rivalry between the two forces.
To win this war both the universe have to bond and fight as a team.
At any given time there will be N DC superheroes and M Marvel Superheroes teaming up together. It’s your responsibility to make sure they fight as a team and to achieve this you have to lineup the heroes so that there are neither two adjacent DC nor two adjacent marvel superheroes. How many such arrangements are possible? Find the count modulo 10^9+7. Also, two arrangements that result from reversing each other are distinguished. The Fate of humanity lies in your hands. Best of Luck

Constraints
1≤N, M≤10⁵

Input Format
Input is given from Standard Input in the following format:
N M

Output Format
Print the number of possible arrangements, modulo 10^9+7

Example 1
Input:
2 2

Output:
8

Explanation:
We will denote the DC superheroes by A and B, and the Marvel Superheroes by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.

Log In to solve the Question