F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Infoplane in Tina Town

Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 3025    Accepted Submission(s): 777


Problem Description
There is a big stone with smooth surface in Tina Town. When people go towards it, the stone surface will be lighted and show its usage. This stone was a legacy and also the center of Tina Town¡¯s calculation and control system. also, it can display events in Tina Town and contents that pedestrians are interested in, and it can be used as public computer. It makes people¡¯s life more convenient (especially for who forget to take a device).

Tina and Town were playing a game on this stone. First, a permutation of numbers from $1$ to $n$ were displayed on the stone. Town exchanged some numbers randomly and Town recorded this process by macros. Town asked Tine,¡±Do you know how many times it need to turn these numbers into the original permutation by executing this macro? Tina didn¡¯t know the answer so she asked you to find out the answer for her.

Since the answer may be very large, you only need to output the answer modulo $3*{2}^{30}+1=3221225473$ (a prime).
 

Input
The first line is an integer $T$ representing the number of test cases. $ T \leq 5$

For each test case, the first line is an integer $n$ representing the length of permutation. $ n \leq 3*{10}^{6} $

The second line contains $n$ integers representing a permutation $A_1...A_n$. It is guaranteed that numbers are different each other and all $A_i$ satisfies ( $1 \leq A_i \leq n$ ).
 

Output
For each test case, print a number $ans$ representing the answer.
 

Sample Input
2 3 1 3 2 6 2 3 4 5 6 1
 

Sample Output
2 6
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 08:57:07, Gzip enabled