Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Meeting Table

By Hasinur_ · Limits 1s, 512 MB

Let there be three groups of people waiting to attend a meeting. There are N\textbf N people in each group. There is a round table in the meeting room. The coordinator wants them to sit in a way around the table that there will be no two-person of the same group sitting adjacently. He decides to make such an arrangement step by step.

  • Step 1: In this step there will be N\textbf N chairs and people of the first group will enter the room and sit adjacently.

  • Step 2: People of second group will enter the room. The coordinator will provide N\textbf N more chairs. Note that first group has entered and sat already. Second group of people will take seat in a way that there will be no two person of the same group sitting adjacently.

  • Step 3: People of third group will enter the room. The coordinator will provide N\textbf N more chairs. Note that first and second group has entered and sat already. Third group of people will sit around the table in a way that there will be no two person of the same group sitting adjacently.

When a group enters the room and sits they will not alter the order of sitting arrangement of previous group.

You will be given the number of people in each group. Your task is to calculate how many ways they can sit around the table. Two ways are considered same if rotating one arrangement any number of times can form the other arrangement.

Input

First line of the input file will contain a single positive integer T\textbf{T} (1T106)(1\leq T \leq 10^{6}) which denotes the number of test cases.
Each of the next T\textbf T lines will contain one integer N\textbf N (1N107)(1\leq N \leq 10^{7}) where
N\textbf N = Number of people in each group.

Output

For each test case print the number of ways they can sit in a linemod(109+7)\mod (10^{9}+7)

Sample

InputOutput
2
1
2
2
24

Discussion

Statistics


70% Solution Ratio

sakib_muhitEarliest, 1M ago

AungkurFastest, 0.3s

sayeef006Lightest, 90 MB

abid1729Shortest, 245B

Submit

Login to submit

Editorial

Step 1: First group can be sitted in (N−1)!\textbf (N-1)!(N−1)! different ways. (Why?) Step 2: Secon...

Related Contests