# I love math

Time Limit: 1000 ms

Memory Limit: 65535 ms

## Description

There are n numbers( 1 ~ n ) stand in an order . Now give you a sequence.Please deal with the n numbers using the sequence.
such as :
n numbers : 1 2 3 4 5  ( sequence 1 )
a sequence: 2 1 4 3 5  ( sequence 2 )

sequence 1 change into 2 1 4 3 5 by the sequence 2 once.
sequence 1 change into 1 2 3 4 5 by the sequence 2 twice.

so the answer is 2.It means sequence 1 need two times go back to itself.

## Input

There are multiple test cases.The first line contain a integer t( t <= 1000 ), indicate t cases.For each case,the first line contain a integer n.next two line contain two sequence (sequence 1 and sequence 2 )

## Sample Input

1
5
2 1 3 4 5
1 3 2 4 5

HINT:

## Sample Output

2


None