{"raw_statement":[{"iden":"problem statement","content":"Snuke's mother gave Snuke an undirected graph consisting of $N$ vertices numbered $0$ to $N-1$ and $M$ edges. This graph was connected and contained no parallel edges or self-loops.\nOne day, Snuke broke this graph. Fortunately, he remembered $Q$ clues about the graph. The $i$\\-th clue ($0 \\leq i \\leq Q-1$) is represented as integers $A_i,B_i,C_i$ and means the following:\n\n*   If $C_i=0$: there was exactly one simple path (a path that never visits the same vertex twice) from Vertex $A_i$ to $B_i$.\n*   If $C_i=1$: there were two or more simple paths from Vertex $A_i$ to $B_i$.\n\nSnuke is not sure if his memory is correct, and worried whether there is a graph that matches these $Q$ clues. Determine if there exists a graph that matches Snuke's memory."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 10^5$\n*   $N-1 \\leq M \\leq N \\times (N-1)/2$\n*   $1 \\leq Q \\leq 10^5$\n*   $0 \\leq A_i,B_i \\leq N-1$\n*   $A_i \\neq B_i$\n*   $0 \\leq C_i \\leq 1$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$ $Q$\n$A_0$ $B_0$ $C_0$\n$A_1$ $B_1$ $C_1$\n$\\vdots$\n$A_{Q-1}$ $B_{Q-1}$ $C_{Q-1}$"},{"iden":"sample input 1","content":"5 5 3\n0 1 0\n1 2 1\n2 3 0"},{"iden":"sample output 1","content":"Yes\n\nFor example, consider a graph with edges $(0,1),(1,2),(1,4),(2,3),(2,4)$. This graph matches the clues."},{"iden":"sample input 2","content":"4 4 3\n0 1 0\n1 2 1\n2 3 0"},{"iden":"sample output 2","content":"No"},{"iden":"sample input 3","content":"10 9 9\n7 6 0\n4 5 1\n9 7 0\n2 9 0\n2 3 0\n4 1 0\n8 0 0\n9 1 0\n3 0 0"},{"iden":"sample output 3","content":"No"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}