Correct and detailed answer will upvoted else downvoted . Skip if you don't know.   Monocarp is the mentor of the Berland State University programming groups. He chose to form a problemset for an instructional meeting for his groups.    Monocarp has n issues that none of his understudies

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 and detailed answer will upvoted else downvoted . Skip if you don't know.

 

Monocarp is the mentor of the Berland State University programming groups. He chose to form a problemset for an instructional meeting for his groups. 

 

Monocarp has n issues that none of his understudies have seen at this point. The I-th issue has a subject man-made intelligence (an integer from 1 to n) and a trouble bi (an integer from 1 to n). All issues are unique, that is, there are no two assignments that have a similar theme and trouble simultaneously. 

Monocarp chose to choose precisely 3 issues from n issues for the problemset. The issues ought to fulfill somewhere around one of two conditions (potentially, both): the subjects of each of the three chose issues are unique; the troubles of every one of the three chose issues are unique. Your errand is to decide the number of ways of choosing three issues for the problemset. 

Input :The primary line contains a solitary integer t (1≤t≤50000) — the number of testcases. The primary line of each testcase contains an integer n (3≤n≤2⋅105) — the number of issues that Monocarp have. In the I-th of the accompanying n lines, there are two integers computer based intelligence and bi (1≤ai,bi≤n) — the theme and the trouble of the I-th issue. 

It is ensured that there are no two issues that have a similar subject and trouble simultaneously. The amount of n over all testcases doesn't surpass 2⋅105. 

Output :Print the number of ways of choosing three preparing issues that meet both of the prerequisites depicted in the assertion.

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
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