| The 2018 ICPC Asia Qingdao Regional Programming Contest (The 1st Universal Cup, Stage 9: Qingdao) |
|---|
| Finished |
PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parachute onto an island and scavenge for weapons and equipment to kill others while avoiding getting killed themselves. Airdrop in this game is a key element, as airdrops often carry with them strong weapons or numerous supplies, helping players to survive.
Airdrop in the game(?)Consider the battle field of the game to be a two-dimensional plane. An airdrop has just landed at point (x0, y0) (both x0 and y0 are integers), and all the n players on the battle field, where (xi, yi) (both xi and yi are integers) indicates the initial position of the i-th player, start moving towards the airdrop with the following pattern:
But the battle is tough and it's almost impossible for all the players to arrive at the airdrop safely. If two or more players meet at point (x', y') other than (x0, y0), where both x' and y' are integers, they will fight and kill each other and none of them survive.
BaoBao is a big fan of the game and is interested in the number of players successfully arriving at the position of the airdrop, but he doesn't know the value of x0. Given the value of y0 and the initial position of each player, please help BaoBao calculate the minimum and maximum possible number of players successfully arriving at the position of the airdrop for all
, where
is the set of all integers (note that x0 can be positive, zero or negative).
There are multiple test cases. The first line of the input contains an integer T, indicating the number of test cases. For each test case:
The first line contains two integers n and y0 (1 ≤ n ≤ 105, 1 ≤ y0 ≤ 105), indicating the number of players and the y value of the airdrop.
For the following n lines, the i-th line contains two integers xi and yi (1 ≤ xi, yi ≤ 105), indicating the initial position of the i-th player.
It's guaranteed that the sum of n in all test cases will not exceed 106, and in each test case no two players share the same initial position.
For each test case output one line containing two integers
and
separated by one space.
indicates the minimum possible number of players successfully arriving at the position of the airdrop, while
indicates the maximum possible number.
3
3 2
1 2
2 1
3 5
3 3
2 1
2 5
4 3
2 3
1 3
4 3
1 3
0 3
2 2
We now explain the first sample test case.
To obtain the answer of
, one should consider x0 = 3. The following table shows the position of each player at the end of each time unit when x0 = 3.
| Time | Player 1 | Player 2 | Player 3 |
| 0 | (1, 2) | (2, 1) | (3, 5) |
| 1 | (2, 2) | (2, 2) | (3, 4) |
| 2 | eliminated | eliminated | (3, 3) |
| 3 | eliminated | eliminated | (3, 2) |
To obtain the answer of
, one should consider x0 = 2. The following table shows the position of each player at the end of each time unit when x0 = 2.
| Time | Player 1 | Player 2 | Player 3 |
| 0 | (1, 2) | (2, 1) | (3, 5) |
| 1 | (2, 2) | (2, 2) | (3, 4) |
| 2 | (2, 2) | (2, 2) | (3, 3) |
| 3 | (2, 2) | (2, 2) | (3, 2) |
| 4 | (2, 2) | (2, 2) | (2, 2) |
| Name |
|---|


