Our favorite Lawyer Saul Goodman is busy saving lives of criminals. Then suddenly Mike comes into his office and gives him a problem which needs to be solved as soon as possible. Saul assures Mike that the problem will be solved within an hour. Mike questions him, "Who will solve this problem?".
In reply, Goodman says -
The problem statement is -
Given a 10^6 * 10^6 matrix with each cell initially consisting of zero values. The input given consists of co-ordinates of cells which have to be marked as 1. Let’s call them true cells. We have to find the number of pairs of such true cells which are in the same diagonal.
Can you help him out?
The first line contains an integer 'T' denoting the total number of test cases. In each test case, the first line contains integer ‘N’ denoting the number of true cells in the matrix. The following N lines contain the location of the true cells.
Print the total number of pairs of true cells which are in the same diagonal.
1<=Coordinates of cells<=1000000