Let there be three groups of people waiting to attend a meeting. There are 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 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 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 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.
First line of the input file will contain a single positive integer which denotes the number of test cases.
Each of the next lines will contain one integer where
= Number of people in each group.
For each test case print the number of ways they can sit in a line
2 1 2
Login to submit
Step 1: First group can be sitted in (N−1)!\textbf (N-1)!(N−1)! different ways. (Why?) Step 2: Secon...