Напомена: ово је незванична копија задатака. Као таква, не гарантује се да ће овај сајт бити одржаван, и немојте се изненадити ако са њега задаци одједном нестану.

The famous TV chef Epirka is planning the next season of his show, which will contain \(N\) episodes about dishes \(X_1, X_2, \dots, X_N\) (which do not have to be unique – he might film multiple episodes about the same dish). To keep things simple, we’ll represent the dishes by numbers from \(1\) to \(N\): if \(X_i = x\), the \(i\)-th episode will be about the dish \(x\).

He has \(N\) recipes \(Y_1, Y_2, \dots, Y_N\), which are also represented by numbers. Recipes are not enough to make the show interesting, so he also needs a scenario: he came up with (again) \(N\) scenarios \(Z_1, Z_2, \dots, Z_k\), where \(Z_i = z\) means that the \(i\)-th scenario can be used to film an episode featuring the dish \(Y_{z}\).

Now that he wrote the list of episodes, recipes, and dishes, he is interested in the number of ways in which he can start filming. That is, he wants to know the number of ways in which he can choose an episode \(i\) and an appropriate scenario \(j\). In other words, he wants to know the number of ordered pairs \((i, j)\) for which \(X_i = Y_{Z_j}\).

Input format

The first line of standard input contains one integer \(N\): the number of episodes, recipes, and scenarios.

The second line contains \(N\) integers \(X_1, X_2, \dots, X_N\), where \(X_i\) is the dish featured in the \(i\)-th episode.

The third line contains \(N\) integers \(Y_1, Y_2, \dots, Y_N\), where \(Y_j\) is the dish made using the \(j\)-th recipe.

The fourth line contains \(N\) integers \(Z_1, Z_2, \dots, Z_N\), where \(Z_k\) is the recipe used in the \(k\)-th scenario. Scenarios are indexed starting from 1.

Output format

Your program should print a single integer to the standard output: the number of ways in which it is possible to choose an episode and a scenario, so that the recipe used in that scenario makes the dish featured in the episode.

Sample 1

Input

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

Output

6

Explanation

If he decides to film the first episode, he will make the dish \(1\), which is only made using the second recipe. There are two scenarios for that recipe: the third and the fourth.

Similarly, the second episode can be filmed using the third or fourth scenario.

The third episode features dish \(4\), which isn’t used in any of the scenarios.

The fourth episode features dish \(3\), which can be made using the first or the third recipe. For the first, he has scenario \(1\), and for the third, scenario 2$, so he (again) has two scenario choices.

Therefore, there are \(2 + 2 + 0 + 2 = 6\) options in total.

Sample 2

Input

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

Output

10

Constraints

Testcases are split into five disjoint groups: