#P12813. [AMPPZ 2019] Donuts

[AMPPZ 2019] Donuts

Description

A set SS of integer coordinate points in a plane is a donut, if there exists a midpoint (a,b)(a, b) and two radii LL and RR (with integer a,b,L,Ra, b, L, R and non-negative radii) such that SS is precisely the set of all points whose distance from (a,b)(a, b) is in the interval (L,R](L, R]. Formally,

$$S = \{(x, y) \in \mathbb{Z} \times \mathbb{Z} : L < \text{dist}((x, y), (a, b)) \leq R\},$$

where dist\text{dist} denotes standard plane distance.

We begin with an empty set and add points one by one. Determine, after every added point, if the set is currently a donut.

Please note an exceptionally low memory limit (8MB) for this problem.

Input Format

The first line of input contains the number of points nn (2107n2.51072 \cdot 10^7 \leq n \leq 2.5 \cdot 10^7). Each of the next nn lines describes a single added point, giving its coordinates separated by a single space. The coordinates are integers of absolute value not greater than 5000. All the given points are distinct.

Output Format

For every point output (in a separate line) TAK\texttt{TAK}, if after adding this point the set is a donut, and NIE\texttt{NIE}, if it isn’t.

12
4 1
3 2
3 0
2 3
1 0
0 1
1 2
2 -1
2 2
3 1
2 0
1 1
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
NIE
NIE
NIE
TAK

Hint

Example: The example is given only for explaining the input format, and it obviously does not satisfy the n2107n \geq 2 \cdot 10^7 condition (though it satisfies all the others). Your program will not be checked on the example test.