M found two papers and a pencil in his room (as you know it's so valuable for a prisoner). a weighted (weights are either \(0\) or \(1\)) graph is drawn on the first paper.
M is forced to draw a spanning tree of the graph (which is drawn on the first paper) on the second paper which includes odd number of \(1\) weighted edges.
Can M draw a spanning tree with the conditions described above?
Input
First line contains two integers \(n, m\), number of first paper graph's vertices and number of first paper graph's edges.
Each of the following \(m\) lines contains \(v_i, u_i\) and \(w_i\) separated space describing graph's \(i\)th edge's vertices(\(v_i, u_i\)) and its weight (\(w_i\)).
Output
In the only line of output print YES if M can draw a spanning tree of the first paper's graph with odd number of \(1\) weighted edges and otherwise print NO.
Constraints
\(1 \leq n, m \leq 3 \times 10^5\)
It is guaranteed that there is no multiple edges or self loops in the graph.
There is only one spanning tree which has \(3\) number of \(1\) weighted edges.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor