SP4881 AMBIG - Words on graphs

Description

N/A

Input Format

The input is a directed (multi)graph. The first line gives the number of edges M and the number of nodes N (>=2). Then each edge is described by a line of the form "FROM TO LABEL". Nodes (FROM, TO) are numbers in the range 0.. N-1 and labels are also numbers. All numbers in the input are nonnegative integers

Output Format

Print "YES" if there are two distinct walks with the same labelling from node 0 to node 1, otherwise print "NO".