Bajtazar wants to build a racetrack in Byteotia. Bajtymon competes for the same money and would rather build a ski jump. Both projects are expensive, so the two men ask the king of Byteotia for funding.
The king funds exactly one of them, the racetrack or the ski jump. Before he decides he asks the Chief Adviser, who heads the hierarchy of royal advisers. An adviser is one of two kinds. An expert gives a recommendation on his own, and every other adviser heads a team of advisers. A team head recommends the option that the majority of his team members support. Every team has an odd number of members, so the majority is always settled. The final recommendation therefore depends only on what the experts support, an expert being an adviser who heads no team. Every adviser other than the Chief Adviser has exactly one superior.
Bajtazar and Bajtymon do not wait idly. They persuade the experts. Persuading one expert takes exactly one day, and a persuaded expert never changes his mind. Some experts already hold an opinion at the start and will not change it.
Every day at dawn Bajtazar picks one undecided expert and visits him to win him over to the racetrack. Bajtymon does not get up that early, so later the same day he picks one of the remaining undecided experts and wins him over to the ski jump. That is why he loses the chance to persuade the expert Bajtazar visited that day. If no undecided expert is left that day, Bajtymon persuades nobody. The two act this way until every expert holds an opinion. Both of them know the hierarchy of advisers.
Decide whether Bajtazar can plan his persuading so that the Chief Adviser recommends building the racetrack, whatever Bajtymon does.
The first line contains one integer n (2≤n≤1000), the number of advisers. The advisers are numbered from 1 to n, and adviser 1 is the Chief Adviser. The i-th of the next n lines describes adviser i. The line starts with an integer ci (−2≤ci≤n). If ci≤0, then adviser i is an expert and the line contains only ci. The values −2, −1 and 0 mean that he is for the racetrack, for the ski jump, and undecided, respectively. If ci≥1, then ci is odd and adviser i heads a team of ci members whose numbers follow on the rest of the line. Every adviser with a number greater than 1 belongs to exactly one team.
If Bajtazar cannot persuade the experts in a way that makes the Chief Adviser recommend the racetrack, print one line with the word NIE. Otherwise print two lines. The first line contains the word TAK and an integer d. Here d counts the ways Bajtazar can choose the expert to persuade on the first day such that, playing optimally on the later days, he is still sure of the favorable recommendation. The second line contains the numbers of those d experts in increasing order. If every expert already holds an opinion at the start and the recommendation favors Bajtazar, print d=0 and leave the second line empty.