{"raw_statement":[{"iden":"problem statement","content":"Given are three sequences of length $N$ each: $A = (A_1, A_2, \\dots, A_N)$, $B = (B_1, B_2, \\dots, B_N)$, and $C = (C_1, C_2, \\dots, C_N)$, consisting of integers between $1$ and $N$ (inclusive).\nHow many pairs $(i, j)$ of integers between $1$ and $N$ (inclusive) satisfy $A_i = B_{C_j}$?"},{"iden":"constraints","content":"*   $1 \\leq N \\leq 10^5$\n*   $1 \\leq A_i, B_i, C_i \\leq N$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n$B_1$ $B_2$ $\\ldots$ $B_N$\n$C_1$ $C_2$ $\\ldots$ $C_N$"},{"iden":"sample input 1","content":"3\n1 2 2\n3 1 2\n2 3 2"},{"iden":"sample output 1","content":"4\n\nFour pairs satisfy the condition: $(1, 1), (1, 3), (2, 2), (3, 2)$."},{"iden":"sample input 2","content":"4\n1 1 1 1\n1 1 1 1\n1 2 3 4"},{"iden":"sample output 2","content":"16\n\nAll the pairs satisfy the condition."},{"iden":"sample input 3","content":"3\n2 3 3\n1 3 3\n1 1 1"},{"iden":"sample output 3","content":"0\n\nNo pair satisfies the condition."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}