{"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\"\u003eConsider a 2 × n grid graph with nodes (x, y) where x ∈ {0, 1} and y ∈ {1, 2, · · · , n}. The initial graph has 3n - 2 edges connecting all pairs of adjacent nodes.\u003cbr\u003eYou need to maintain the graph with two types of different adjustments. The first one, denoted by “1 $x_0$ $y_0$ $x_1$ $y_1$”,adds an new edge between the nodes ($x_0, y_0$) and ($x_1, y_1$) which was not exist. The second one, denoted by“2 $x_0$ $y_0$ $x_1$ $y_1$”, erases an existed edge between the nodes ($x_0, y_0$) and ($x_1, y_1$).\u003cbr\u003eIt is sure that, for each adjustment, ($x_0, y_0$) and ($x_1, y_1$) were adjacent in the original grid graph. That is say thateither they share the same x coordinate and |$y_0 - y_1$| \u003d 1, or they share the same y coordinate and |$x_0 - x_1$| \u003d 1.\u003cbr\u003eAfter each adjustment, we guarantee the connectedness of the graph and you need to calculate the number of bridges in the current graph.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input contains an integer T (1 ≤ T ≤ 1001) which is the total number of test cases. For each test case, the first line contains integers n (1 ≤ n ≤ 200000) and m (0 ≤ m ≤ 200000); n indicates the size of the graph\u003cbr\u003eand m is the number of adjustments. Each of the following m lines contains an adjustment described as above.\u003cbr\u003eOnly one case satisfies n + m ≥ 2000.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output m lines, each of which contains the number of bridges."}},{"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\u003e2\r\n4 8\r\n2 0 3 1 3\r\n2 0 2 1 2\r\n2 0 4 1 4\r\n1 0 2 1 2\r\n1 0 3 1 3\r\n2 0 1 1 1\r\n1 0 4 1 4\r\n2 1 2 1 3\r\n6 2\r\n2 1 2 1 3\r\n2 0 4 0 5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n0\r\n7\r\n4\r\n2\r\n4\r\n2\r\n4\r\n1\r\n2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}