In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Byteotian State Railways decided to keep up with the times and introduce to their offer an InterCity connection. Because of lack of efficient engines, clean carriages and straight tracks it was possible to establish only one such a connection. The lack of any computer system for seat reservation was another obstacle. Writing the main part of this system is your task.
For simplicity we assume that the InterCity connection runs through cities numbered successively from to (the starting city has the number , and is the number of the ending city). There are seats in the train and transporting more passengers between any two successive stations is not allowed.
The computer system is to receive successive requests and determine whether they may be fulfilled. A request is accepted when in the given section of the railway line there is enough vacant seats in the train. Otherwise it is rejected. Partial accepting of a request is not allowed, e.g. for a part of a route or for less passengers. After accepting a request, the number of vacant seats in the train is updated. The requests are processed successively in the order of coming.
Write a program which:
In the first line of the standard input there are three integers , and (, , ) separated by single spaces. The numbers denote respectively: the number of cities on the railway line, the number of seats in the train, and the number of requests. In the following lines there are consecutive requests written. In the line of number there is the -th request described. The description consists of three integers , and (, ) separated by single spaces. They denote: the number of the station of origin, the number of the destination station and the requested number of seats, respectively.
Your program should write lines to the standard output. In the -th line there should be exactly one character:
For the input data:
4 6 4 1 4 2 1 3 2 2 4 3 1 2 3
the correct result is:
T T N N
Task author: Tomasz Walen.