Problem H

Counting Rectangles

Input: Standard Input

Output: Standard Output

Time Limit: 3 Seconds

 

Given n points on the XY plane, count how many regular rectangles are formed. A rectangle is regular if and only if its sides are all parallel to the axis.

 

Input

The first line contains the number of tests t(1<=t<=10). Each case contains a single line with a positive integer n(1<=n<=5000), the number of points. There are n lines follow, each line contains 2 integers x, y (0<=x, y<=109) indicating the coordinates of a point.

 

Output

For each test case, print the case number and a single integer, the number of regular rectangles found.

 

Sample Input                             Output for Sample Input

2

5

0 0

2 0

0 2

2 2

1 1

3

0 0

0 30

0 900

Case 1: 1

Case 2: 0


Problemsetter: Rujia Liu, Member of Elite Problemsetters' Panel

Special Thanks: IOI2003 China National Training Team