Byteazar has decided to tour the space stations that exist around Mars. All the Martian space stations lie on the circumference of a single circle. Byteazar lands at one of them and then moves along the circle using a special vehicle powered by a suitable fuel. One litre of this fuel lets him travel exactly one metre.
Each station holds a different amount of fuel. Byteazar may refuel at the station he is currently in, but he cannot take more fuel than is available there (the capacity of his fuel tank is unlimited). The fuel he takes must be enough to reach the next station.
Byteazar has to decide where to land so that he can visit all of the stations. At the end he must return to the station where he landed. Throughout the journey Byteazar travels along the circumference, always continuing in one of the two possible directions.
Write a program which:
The first line contains a single integer N (3≤N≤1,000,000), the number of space stations on Mars. The stations are numbered from 1 to N.
Each of the next N lines describes one station and one distance. The (i+1)-th line contains two integers pi and di (pi≥0, di>0). Here pi is the amount of fuel (in litres) available at the i-th station, and di is the distance (in metres) between the i-th and (i+1)-th station (where dN is the distance between the N-th and the 1st station).
The total amount of available fuel and the total of all distances between the stations each do not exceed 2,000,000,000.
Print N lines. The i-th line should contain TAK (Polish for “yes”) if Byteazar can land at the i-th station, or NIE (Polish for “no”) if it is not possible.