Well Off

아직 제출이 없습니다시간 제한2초메모리 제한128 MB

문제

Thanks to his hard work, John, formerly Johnny, has become a member of the respectable Well Off Club. The club has nn members, numbered from 11 to nn; the ii-th club member has a fortune worth x_ix\_i. These can be arbitrary numbers, including negative ones. The reason for this is that the club membership is for life, i.e., neither impoverishment nor even bankruptcy results in an ousting.

The club members take pleasure in comparing their asset values, but they shun telling the number directly; it is their custom to engage in a conversation that lets them establish that their fortunes x_ix\_i and x_jx\_j satisfy one of the inequalities x_i+x_j>0x\_i + x\_j >0, x_ix_j>0x\_i - x\_j > 0, x_i+x_j>0-x\_i + x\_j > 0, or x_ix_j>0-x\_i - x\_j > 0.

Johnny (over-)heard many such inequalities today at the club, but he suspects that some of the members are lying. Help him determine if all the inequalities could possibly be true, i.e., if they can be simultaneously satisfied by some set of fortunes. Write a program that: reads the inequalities heard by Johnny, determines if they are satisfiable, and prints the answer to the standard output.

입력

In the first line of input there are two integers, nn and mm (1n100,0001 \le n \le 100\\,000, 1m500,0001 \le m \le 500\\,000), separated by a single space. These specify the number of club members and the number of inequalities relating their fortunes, respectively.

Each of the mm lines that follow describes one inequality, encoded by a + or - sign, an integer ii (1in1 \le i \le n), another + or - sign, and an integer jj (1jn1 \le j \le n), separated by single spaces.  These correspond to the inequality ±x_i±x_j>0\pm x\_i \pm x\_j > 0 (with the signs as preceding ii and jj in the description). It might happen that i=ji=j.

출력

The first and only line of the output should contain a single word: "TAK" if the system of inequalities is satisfiable, and  "NIE" otherwise. % (Naturally, these are the Polish words for yes and no.)

힌트

In Sample 1, system of inequalities is satisfiable, e.g. by x_1=3x\_1 = 3, x_2=2x\_2 = 2, x_3=1x\_3 = 1.

In Sample 2, system of inequalities is not satisfiable.