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

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 12RP
icon
Related questions
Question

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≤ai≤a), where computer based intelligence is the number of the kid in the pair with the number I. 

 

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

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole