Section: 3, Score: 33, Time limit per test: 30 seconds, Memory limit per test: 512MB, Input: stdin, Output: stdout
The much-awaited Codegoda is here. The organizer is trying to form teams to write and test problems, but forming teams is not an easy task. The organizer has made many attempts but every time a team is missing a tester or has only testers. A good team should have a mentor, and some volunteer(s) to write and test problems. The organizer writes an algorithm to form perfect teams, but his algorithm is not efficient for large constraints. Now, you must help him to write a slightly different solution for large constraints.
There are
The first line of the input contains an integer
The next
For each test case print one integer, the number of ways to form teams, in a new line. The answer can be large, so print it modulo 1,000,000,007 (AKA James Bond Prime).
2
2 2 2 2
3 3 3 3
8
162
In 1st case, If we put only one volunteer of type N in a team and others in the second team, we can form the teams in 4 possible ways.
If we put one volunteer of type N and one volunteer of type M in each team, we can form the teams in 4 possible ways too.
So, we can make teams in 8 possible ways.
3
3 5 9 1
6 3 3 3
8 10 1 1
9
4374
1