CHAMPS  Michel and the championship
Michel is participating in a championship where each participant have p_{i} (0<=i<=N1) points. He knows for some pairs of participants an inequality between the points of each one, in the form p_{A} p_{B} >= C. Now he wants to know if his data is correct, i.e., if its possible to assign points for each participant and satisfy all the inequalities.
Input
The input consists of several test cases (at most 150). The first line of each test case consists of two integers N and M (1<=N<=500, 0<=M<=5000). Then follow M lines of three integers A, B and C, indicating that p_{A} p_{B} >= C (0<=A,B<=N1, C<=20000).
Output
Print a single line for each test case with 'y' if the data is valid or 'n' if its not.
Example
Input 2 2 0 1 2 1 0 2 4 4 0 1 1 1 2 1 2 3 2 3 0 1 4 4 0 1 1 1 2 1 2 3 3 3 0 1 Output n n y
hide comments
smso:
20180805 08:12:39
got SIGSEGV, input may contain characters other than numbers, space and newline 

Dario Sindicic:
20150403 09:47:29
0<=A,B<=N1


Akimil:
20150402 22:42:35
What is the number of test cases? Until when we read? 

Milan:
20150402 01:21:21
I don't understand what is N supposed to do. Someone please explain me this part, thanks. Last edit: 20150402 01:23:37 

Petar Bosnjak:
20150401 18:20:57
We should read input till EOF? 

Nikola:
20150401 15:34:13
Can someone please explain this better with less conditions like: pA pB >= C and 0<=A,B<=N1, C<=20000? 
Added by:  Marcos Kawakami 
Date:  20120219 
Time limit:  1.542s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Author: Guilherme Souza (guirns) 