Officially, you know k conceivable one-kid one-young lady sets. You really want to pick two of these sets with the goal that no individual is in more than one sets. For instance, if a=3, b=4, k=4 and the couples (1,2), (1,3), (2,2), (3,4) are prepared to move together (in each pair, the kid's number starts things out, then, at that point
Correct answer will be upvoted else downvoted. Computer science.
Officially, you know k conceivable one-kid one-young lady sets. You really want to pick two of these sets with the goal that no individual is in more than one sets.
For instance, if a=3, b=4, k=4 and the couples (1,2), (1,3), (2,2), (3,4) are prepared to move together (in each pair, the kid's number starts things out, then, at that point, the young lady's number), then, at that point, the accompanying blends of two sets are conceivable (not all imaginable choices are recorded underneath):
(1,3) and (2,2);
(3,4) and (1,3);
Yet, the accompanying mixes are unrealistic:
(1,3) and (1,2) — the main kid enters two sets;
(1,2) and (2,2) — the subsequent young lady enters two sets;
Track down the number of ways of choosing two sets that match the condition above. Two different ways are considered unique if they comprise of various sets.
Input
The primary line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow.
The principal line of each experiment contains three integers a, b and k (1≤a,b,k≤2⋅105) — the number of young men and young ladies in the class and the number of couples prepared to move together.
The second line of each experiment contains k integers a1,a2,… ak. (1≤
The third line of each experiment contains k integers b1,b2,… bk. (1≤bi≤b), where bi is the number of the young lady in the pair with the number I.
It is ensured that the amounts of a, b, and k over all experiments don't surpass 2⋅105.
It is ensured that each pair is indicated all things considered once in one experiment.
Output
For each experiment, on a different line print one integer — the number of ways of picking two sets that match the condition above
Step by step
Solved in 4 steps with 1 images