The Lion King
Time limit2sMemory limit512 MB
Count the five-point star configurations among N given points, printing the total modulo 1000000007 for each test case.
- Level
Medium5 of 10
- Topics
- Prefix sum, Combinatorics, Brute force
- Solved
- No attempts yet
Problem
In the Pride Lands of Africa, a lion rules the animals as king. When King Mufasa and Queen Sarabi have a son named Simba, Mufasa's younger brother Scar feels envy and resentment, since his nephew now takes his place as heir to the throne.
After Simba grows into a young cub, Mufasa takes him on a tour of the Pride Lands and teaches him the duties of a king and the circle of life. They spend the whole day on the tour, and now it is time to sleep.
Simba is still young and does not fall asleep quickly, so he keeps nudging his father to talk. Mufasa is very tired and wants to sleep, so he asks Simba a hard question to keep him busy: how many stars are there in the sky?
Simba sees the sky as an infinite 2D grid with some glowing points.

A star is a set of five points , , , , and that satisfies these conditions:
Can you help Simba answer this question as soon as possible?
Input
The first line contains a single integer , the number of test cases (). Each test case starts with one line containing an integer , the number of points in the sky (). The next lines each contain two integers and separated by a single space (), the coordinates of a point.
Output
For each test case, print one line with the number of stars Simba can see in the sky, modulo . Each point can belong to multiple stars.