#C. ABC202C - Made Up

    Type: Default 1000ms 256MiB

ABC202C - Made Up

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Score : 300 points

Problem Statement

Given are three sequences of length N each: A=(A1,A2,,AN), B=(B1,B2,,BN), and C=(C1,C2,,CN), consisting of integers between 1 and N (inclusive).

How many pairs (i,j) of integers between 1 and N (inclusive) satisfy Ai=BCj?

Constraints

  • 1N105
  • 1Ai,Bi,CiN
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A1 A2  AN
B1 B2  BN
C1 C2  CN

Output

Print the number of pairs (i,j) such that Ai=BCj.


Sample Input 1

3
1 2 2
3 1 2
2 3 2

Sample Output 1

4

Four pairs satisfy the condition: (1,1),(1,3),(2,2),(3,2).


Sample Input 2

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

Sample Output 2

16

All the pairs satisfy the condition.


Sample Input 3

3
2 3 3
1 3 3
1 1 1

Sample Output 3

0

No pair satisfies the condition.

ABC202

Not Attended
Status
Done
Rule
IOI
Problem
7
Start at
2023-6-28 14:15
End at
2023-6-28 16:39
Duration
2.4 hour(s)
Host
Partic.
13