{"raw_statement":[{"iden":"problem statement","content":"Squid loves painting vertices in graphs.\nThere is a simple undirected graph consisting of $N$ vertices numbered $1$ through $N$, and $M$ edges. Initially, all the vertices are painted in color $0$. The $i$\\-th edge bidirectionally connects two vertices $a_i$ and $b_i$. The length of every edge is $1$.\nSquid performed $Q$ operations on this graph. In the $i$\\-th operation, he repaints all the vertices within a distance of $d_i$ from vertex $v_i$, in color $c_i$.\nFind the color of each vertex after the $Q$ operations."},{"iden":"constraints","content":"*   $1 ≤ N,M,Q ≤ 10^5$\n*   $1 ≤ a_i,b_i,v_i ≤ N$\n*   $a_i ≠ b_i$\n*   $0 ≤ d_i ≤ 10$\n*   $1 ≤ c_i ≤10^5$\n*   $d_i$ and $c_i$ are all integers.\n*   There are no self-loops or multiple edges in the given graph."},{"iden":"partial score","content":"*   $200$ points will be awarded for passing the testset satisfying $1 ≤ N,M,Q ≤ 2{,}000$."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$a_1$ $b_1$\n$:$\n$a_{M}$ $b_{M}$\n$Q$\n$v_1$ $d_1$ $c_1$\n$:$\n$v_{Q}$ $d_{Q}$ $c_{Q}$"},{"iden":"sample input 1","content":"7 7\n1 2\n1 3\n1 4\n4 5\n5 6\n5 7\n2 3\n2\n6 1 1\n1 2 2"},{"iden":"sample output 1","content":"2\n2\n2\n2\n2\n1\n0\n\nInitially, each vertex is painted in color $0$. In the first operation, vertices $5$ and $6$ are repainted in color $1$. In the second operation, vertices $1$, $2$, $3$, $4$ and $5$ are repainted in color $2$.\n\n![image](https://atcoder.jp/img/agc012/2ab7e180230b159d42d35ea7e555b3b0.png)"},{"iden":"sample input 2","content":"14 10\n1 4\n5 7\n7 11\n4 10\n14 7\n14 3\n6 14\n8 11\n5 13\n8 3\n8\n8 6 2\n9 7 85\n6 9 3\n6 7 5\n10 3 1\n12 9 4\n9 6 6\n8 2 3"},{"iden":"sample output 2","content":"1\n0\n3\n1\n5\n5\n3\n3\n6\n1\n3\n4\n5\n3\n\nThe given graph may not be connected."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}