The Committee of the National Archeological Research in eXploration of Organized Zones (NARXOZ) found an old chest in the Almaty region. But there is a lock on the chest with the password that consists of $$$n$$$ positive numbers.
Luckily, scientists also found the correct version of this list — the one that opens the chest.
So, you are given the two lists of numbers: the password that is now on the lock and the password that opens the chest.
To change the current password into the correct one, you can use this operation:
You can repeat this operation as many times as needed. Your goal is to make the current list exactly the same as the correct list, using the smallest number of operations.
If it is not possible to make the two lists the same, output -1.
NARXOZ is holding a contest: the fastest person who solves this problem will get a great job offer. You want to win — so get to work!
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3*10^5$$$) — the length of the password.
The second line contains $$$n$$$ positive integers — the current version of the password.
The third line contains $$$n$$$ positive integers — the correct version of the password.
All values of the integers are positive and do not exceed $$$10^9$$$.
Print one number — the minimum number of operations needed to turn the current list into the correct list. If it is impossible, print -1.
34 7 31 7 6
3
43 1 4 22 2 3 3
-1
In the first sample we can perform operations in the following order: Swap $$$(1, 2)$$$, swap $$$(2, 3)$$$ and swap $$$(1, 2)$$$. It can be shown, that there is no other option with less number of operations.
In the second sample there is no valid order of operations to get the correct version of the password from the current one.
| Name |
|---|


