In the event of technical difficulties with Szkopuł, please contact us via email at email@example.com.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
Byteazar has decided on going to Mars to tour the space stations there being in existence. All marsian space stations lie on a circumference of a circle. Byteazar lands in one of them and then moves around by means of a special vehicle which is powered by an appropriate fuel. A litre of this fuel allows him to travel one meter. However, the provisions of the fuel are meagre, different quantities of it are available in each space station. Byteazar may refuel in the space station he is currently in, though he cannot get more fuel than it is available in that very place (the capacity of his fuel tank is unlimited). This quantity of fuel should allow him to reach the next space station. Byteazar has to decide where to land, so that he can visit all of the space stations. In the end he has to return to the space station in which he has landed. During his journey Byteazar has to travel on the circumference of the circle, constantly in one of the two possible directions.
Write a programme which:
The first line of the standard input contains a single integer (). It denotes the number of space stations on Mars. The space stations are numbered from to . In the next lines there is a description of all of the stations and the distances between them. The 'st line contains two integers and (, ). The first one denotes the amount of fuel (in litres) available in the 'th space station. The other denotes the distance (in metres) between the 'th and 'st space station (obviously denotes the distance between the 'th and the st space station). The total amount of available fuel, as well as the sum of all distances between the space stations does not exceed .
The programme should write lines to the standard output. The 'th line should contain the word TAK (i.e. yes is Polish), if Byteazar can land in the 'th space station or NIE (i.e. no in Polish) when it is not possible.
For the input data:
5 3 1 1 2 5 2 0 1 5 4
the correct result is:
TAK NIE TAK NIE TAK
Task author: Pawel Parys.