Under construction

Still being built. Things may change

The Lion King

Time limit2sMemory limit512 MB

Summary
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 p1p_1, p2p_2, p3p_3, p4p_4, and p5p_5 that satisfies these conditions:

  • p1.y>p5.yp_1.y > p_5.y
  • p5.y=p2.yp_5.y = p_2.y
  • p3.y,p4.y<p5.yp_3.y, p_4.y < p_5.y
  • p5.x<p1.x<p2.xp_5.x < p_1.x < p_2.x
  • p5.x<p4.x<p1.xp_5.x < p_4.x < p_1.x
  • p1.x<p3.x<p2.xp_1.x < p_3.x < p_2.x

Can you help Simba answer this question as soon as possible?

Input

The first line contains a single integer TT, the number of test cases (1≤T≤2001 \le T \le 200). Each test case starts with one line containing an integer NN, the number of points in the sky (5≤N≤50005 \le N \le 5000). The next NN lines each contain two integers xx and yy separated by a single space (−5000≤x,y≤5000-5000 \le x, y \le 5000), 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 10000000071000000007. Each point can belong to multiple stars.

Examples1

  1. Example 1

    Input
    2
    5
    0 5
    4 4
    -4 4
    2 0
    -2 0
    8
    0 5
    4 4
    -6 4
    2 0
    -1 0
    -5 4
    0 12
    3 0
    
    Expected output
    1
    8