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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education