{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eNoah owns an unrooted tree with $n$ vertices which are numbered from $1$ to $n$. Every morning Noah would like to pick two vertices $u$ and $v$ to get influence from daylight and then the influence spreads through edges, but the influence will be disappeared if it has passed through more than $w$ edges.\u003cbr\u003eYour task is to calculate the number of vertices influenced by the daylight for each day. In addition, input data will be encrypted to make sure your solution is online.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains one integer $T$, indicating the number of test cases.\u003cbr\u003eThe following lines describe all the test cases. For each test case:\u003cbr\u003eThe first line contains two integers $n$ and $m$.\u003cbr\u003eEach of the following $(n - 1)$ lines contains two integers $u$ and $v$, indicating an edge between vertex $u$ and vertex $v$.\u003cbr\u003eLet $\\mathrm{lastans}$ be the last answer before each day. At the beginning day of each test case, $\\mathrm{lastans}$ is initialized as $0$.\u003cbr\u003eEach of the following $m$ lines contains three integers $u\u0027$, $v\u0027$ and $w\u0027$, satifying $u \u003d ((u\u0027 + \\mathrm{lastans}) \\bmod n) + 1$, $v \u003d ((v\u0027 + \\mathrm{lastans}) \\bmod n) + 1$, $w \u003d (w\u0027 + \\mathrm{lastans}) \\bmod n$, which means one day Noah will pick vertices $u$ and $v$ to get influence and the influence will be disappeared if it has passed through more than $w$ edges.\u003cbr\u003e$1 \\leq T \\leq 100$, $1 \\leq n, m \\leq 10^5$, $1 \\leq u, v, u\u0027, v\u0027 \\leq n$, $0 \\leq w\u0027 \u0026lt; n$.\u003cbr\u003eIt is guaranteed that no more than $10$ test cases do not satisfy $n, m \\leq 10^3$ and the size of the standard input file does not exceed $32$ MiB."}},{"title":"Output","value":{"format":"HTML","content":"For each day, print the answer in one line.\u003cbr\u003eIt is guaranteed that the size of the standard output file does not exceed $7$ MiB.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n5 5\r\n1 2\r\n2 3\r\n2 4\r\n3 5\r\n5 1 0\r\n3 4 4\r\n1 2 3\r\n5 1 3\r\n5 1 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n4\r\n5\r\n5\r\n5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eThe decrypted information is the following:\u003cbr\u003eDay 1: u \u003d 1, v \u003d 2, w \u003d 0;\u003cbr\u003eDay 2: u \u003d 1, v \u003d 2, w \u003d 1;\u003cbr\u003eDay 3: u \u003d 1, v \u003d 2, w \u003d 2;\u003cbr\u003eDay 4: u \u003d 1, v \u003d 2, w \u003d 3;\u003cbr\u003eDay 5: u \u003d 1, v \u003d 2, w \u003d 4.\u003cbr\u003e"}}]}