The first line contains an integer n (1≤n≤100000), the number of figurines.
The second line contains n integers p1,p2,…,pn (0≤pk≤n) describing the initial configuration. pk is 0 if figurine k is free, and the parent of figurine k otherwise.
The third line contains n integers q1,q2,…,qn (0≤qk≤n) describing the target configuration in the same format.
Both configurations are valid: every figurine is smaller than its parent, and no two figurines have the same parent.