#P1949. 序列置换

序列置换

    有一个数字序列A{a1,a2,a3,a4 .... an}和一个调整策略T{t1,t2,t3,t4 .... tn},

其中调整策略的序列表示:

    a1将转换到A序列的t1位置,

    a2将转换到A序列的t2位置

    ....

求按照T策略转换多少次能还原A序列(最少一次)。

Input

每组测试数据两行(最多1000组)
第一行一个整数 n (1 <= n <= 200)
第二行 n 个整数 ti (1 <= ti <= n) 任意 ti 不重复

Output

一行一个整数表示答案

Sample Input

4
1 2 3 4
3
2 3 1

Sample Output

</p>
1
3

HINT

Please, do not write the \_\_int64 specifier to read or write 64-bit integers in С++.
It is preferred to use the cin, cout streams or the %lld(long long) specifier.

Source