luogu#P9031. [COCI 2022/2023 #1] Iksevi
[COCI 2022/2023 #1] Iksevi
Background
After writing code for ten years, Vinko decided to change careers and become a potter. On his first day at the new job, he was given a difficult task.
Problem Description
Vinko needs to cover the floor of a concert hall using square tiles. He will not align the tile edges parallel to the walls; instead, he chooses to align the diagonals of the tiles parallel to the walls.
Vinko has not yet decided the tile size, but he knows that all tiles must be the same size, and the diagonal length must be a positive even integer.
The first tile Vinko places will have a corner touching the left wall and the back wall. After that, each tile he places shares at least one full edge with at least one tile that has already been placed. He will repeat this process until the entire square millimeter floor is covered.
Besides being a programmer and a potter, Vinko is also an excellent musician. Because of that, he knows there are points on the floor that are crucial for the hall’s acoustics. If a tile corner lies on one of these points, the acoustics of the hall will improve significantly.

As shown in the figure, the left diagram is a tiling with diagonal length . Under this tiling, the point lies on a tile corner, so it satisfies the condition and greatly improves the acoustics, but the points and do not. The right diagram is a tiling with diagonal length . In this tiling, the point lies on the corners of four tiles, while and do not.
Help Vinko determine, for each of the points, how many tile sizes can make the -th point lie on a tile corner after the floor is fully covered.
Input Format
The first line contains an integer , the number of acoustically important points.
The next lines each contain two integers , representing the distances from the -th acoustically important point to the left wall and the back wall.
Output Format
Output lines, each containing one integer.
Line should contain the number of tile sizes that can make the -th acoustically important point lie on a tile corner.
3
1 4
0 0
0 9
1
0
3
3
5 1
4 3
2 4
0
1
1
Hint
| Subtask | Score | Constraints |
|---|---|---|
This problem is worth points in total.
Translated by ChatGPT 5