Queens Junior
On a chessboard of size N×N, there are K queens placed on different squares. A queen can move any number of squares in a straight line or diagonally. Specifically, a queen can move from a square with coordinates (x, y) to a square with coordinates (x', y') if and only if the absolute differences |x - x'| and |y - y'| are equal and non-zero. We say that one queen threatens another if there is a possible move from the square of the first queen to the square of the second. This relationship is symmetric, meaning if one queen threatens another, then the second queen also threatens the first. A queen is under attack by another if the second queen threatens the first and all squares between them are unoccupied. This relationship is also symmetric.
Your task is to determine two things: the number of pairs of queens that threaten each other and the number of pairs of queens that are under attack by each other.
Input
The first line contains two integers N and K (1 ≤ N ≤ 10^6, 0 ≤ K ≤ 10^5, 1 ≤ x, y ≤ N). Each of the following K lines contains two integers x and y, which specify the coordinates of each queen.
Output
On the first line, output the number of pairs of queens that threaten each other. On the second line, output the number of pairs of queens that are under attack by each other.