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.
Byteasar runs a skate club. Its members meet on a regular basis and train together, and they always use the club's ice-skates. The skate sizes are (by convention) numbered from to . Naturally, each club member has some foot size, but that is not all to it! Skaters have skate size tolerance factor : a skater with foot size can wear skates with sizes from up to . It should be noted, though, that no skater ever wears two skates of different size simultaneously.
To supply the club, Byteasar bought pairs of ice-skates of each size, i.e. from to . As time passes, some people join the club, just as some established members leave it. Byteasar worries if he will have enough skates of appropriate size for every member at each training.
We assume that initially the club has no members at all. Byteasar will give you a sequence of events of the following form: (new) members with foot size have joined/left the club. Right after each such event Byteasar wants to know whether he has enough skates of appropriate size for every club member. He asks you to write a programme that will check it for him.
The first line of the standard input contains four integers , , and (, , , ), separated by single spaces, that denote, respectively: maximum skate size, number of events, number of skate pairs of each size Byteasar initially bought, and the skate size tolerance factor. The following lines contain the sequence of events, one per line. The -th line (for ) holds two integers: and (, ), separated by a single space. If , it means that new members with foot size each have just joined the club. And if , it means that members with foot size each have just left the club. You may assume the sequence is sensible, i.e. someone who never joined the club cannot leave it.
Your programme should print out lines to the standard output. The -th line (for ) should either contain the word TAK (Polish for yes), or the word NIE (Polish for no), depending on whether Byteasar has the skates of appropriate size for every club member right after the -th event.
For the input data:
4 4 2 1 1 3 2 3 3 3 2 -1
the correct result is:
TAK TAK NIE TAK
After all events from the input sequence took place, there are three club members who can wear skates of size 1 or 2, two members who can wear sizes 2 or 3, and three members who can wear sizes 3 or 4. With such list of members two pairs of ice-skates of sizes 1, 2, 3, and 4 each suffice:
Task author: Jakub Radoszewski.