point when he's not preparing for IOI, Little Alawn appreciates playing with riddles of different sorts to animate his cerebrum. Today, he's playing with a riddle that comprises of a 2×n network where each column is a change of the numbers 1,2,3,… ,n. The objective of Little Alawn's
Correct answer will be upvoted else downvoted.
At the point when he's not preparing for IOI, Little Alawn appreciates playing with riddles of different sorts to animate his cerebrum. Today, he's playing with a riddle that comprises of a 2×n network where each column is a change of the numbers 1,2,3,… ,n.
The objective of Little Alawn's riddle is to ensure no numbers on a similar section or line are something very similar (we'll call this condition of the riddle as settled), and to accomplish this he can trade the numbers in any segment. Be that as it may, in the wake of settling the riddle ordinarily, Little Alawn got exhausted and started pondering with regards to the number of conceivable addressed setups of the riddle he could accomplish from an underlying tackled arrangement exclusively by trading numbers in a segment.
Sadly, Little Alawn stalled out while putting in to tackle this more effort issue, so he was contemplating whether you could assist him with it. Discover the appropriate response modulo 109+7.
Input
Each test contains various experiments. The primary line contains the number of experiments t (1≤t≤104). Portrayal of the experiments follows.
The principal line of each experiment contains a solitary integer n (2≤n≤4⋅105).
The following two lines of each experiment portray the underlying condition of the riddle framework. Each line will be a change of the numbers 1,2,3,… ,n and the numbers in every segment and column will be pairwise particular.
It is ensured that the amount of n over all experiments doesn't surpass 4⋅105.
Output
For each experiment output a solitary integer, the number of conceivable settled arrangements of the riddle Little Alawn can accomplish from an underlying addressed design simply by trading numbers in a section. As the appropriate response can be exceptionally enormous, kindly output it modulo 109+7.
Step by step
Solved in 4 steps with 1 images