The dense, whispering woods of the Unknown stretched endlessly before the three. After a particularly perplexing encounter with a musical grumpkin, they found themselves utterly lost. "If only Adham were here," sighed Omar, staring at a tangle of gnarled roots that looked suspiciously like a forgotten road. "He always knows the shortest path."
Just then, a peculiar figure emerged from the shadows – Adham, perched precariously on the back of a majestic, shimmering goose named Halzoom! Halzoom, it turns out, wasn't just any goose; she possessed an innate, almost magical, understanding of the forest's pathways.
Adham, ever the strategist, explained their predicament. The forest, he revealed, was a vast network of $$$N$$$ quaint, peculiar towns, connected by $$$M$$$ winding roads. Each road $$$i$$$ connected two towns, $$$u_i$$$ and $$$v_i$$$, and took a specific number of days, $$$w_i$$$, to traverse. Halzoom's magic wasn't about changing the speed of roads, but about finding the optimal set of paths.
However, there was a catch. Halzoom's magic only worked if they could choose exactly $$$N-1$$$ roads from the existing $$$M$$$ roads to form a specific type of travel network. This chosen set of $$$N-1$$$ roads, which Adham calls a "Halzoom Highway", must satisfy two crucial conditions:
Adham, with a glint in his eye, turned to his friends. "Can you help me figure this out? We need to know if it's even possible to construct such a 'Halzoom Highway'!"
The first line contains two integers $$$N$$$ , $$$M$$$ ($$$1 \le N \le 2 \cdot{10^5}, N - 1 \le M \le \min(2 \cdot{10^5} , \ \frac{n\cdot(n - 1)}{2})$$$).
Then $$$M$$$ lines follow. The $$$i_{th}$$$ line contains 3 integers $$$u_i$$$ , $$$v_i$$$ $$$(1 \leq u_i , v_i \leq n)$$$ and $$$w_i$$$ $$$(1 \leq w_i \leq 10^9)$$$.
Print "YES" if there exists a tree that meets the above conditions , otherwise print "NO".
4 41 2 13 4 111 3 42 4 3
YES
4 41 2 13 4 21 3 42 4 3
NO
| Name |
|---|


