## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Good Pairs CodeChef Solution | CodeChef Problem Solution 2022

You are given arrays $A$ and $B$ of length $N$ each. Determine the number of good pairs.

A pair $\left(i,j\right)$ $\left(1\le i,j\le N\right)$ is said to be good if all of the following conditions are satisfied:

• $i
• ${A}_{i}={B}_{j};$
• ${A}_{j}={B}_{i};$

### Input Format

• First line will contain $T$, the number of test cases. Then the test cases follow.

Description of each test case:

• First line contains an integer $N$ - denoting the length of the arrays.
• Second line contains $N$ space-separated integers ${A}_{1},{A}_{2},\dots {A}_{N}$ - denoting the array $A$.
• Third line contains $N$ space-separated integers ${B}_{1},{B}_{2},\dots {B}_{N}$ - denoting the array $B$.

### Output Format

For each test case, output the number of good pairs.

### Constraints

• $1\le T\le 1000$
• $2\le N\le {10}^{5}$
• $1\le {A}_{i},{B}_{i}\le {10}^{9}$
• Sum of $N$ over all test cases does not exceed $2\cdot {10}^{5}$.