{"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 the following exercise, found in a generic linear algebra textbook.\u003cbr\u003e\u003cbr\u003e Let A be an n × n matrix. Prove that the following statements are equivalent:\u003cbr\u003e\u003cbr\u003e 1. A is invertible.\u003cbr\u003e 2. Ax \u003d b has exactly one solution for every n × 1 matrix b.\u003cbr\u003e 3. Ax \u003d b is consistent for every n × 1 matrix b.\u003cbr\u003e 4. Ax \u003d 0 has only the trivial solution x \u003d 0. \u003cbr\u003e\u003cbr\u003eThe typical way to solve such an exercise is to show a series of implications. For instance, one can proceed by showing that (a) implies (b), that (b) implies (c), that (c) implies (d), and finally that (d) implies (a). These four implications show that the four statements are equivalent.\u003cbr\u003e\u003cbr\u003eAnother way would be to show that (a) is equivalent to (b) (by proving that (a) implies (b) and that (b) implies (a)), that (b) is equivalent to (c), and that (c) is equivalent to (d). However, this way requires proving six implications, which is clearly a lot more work than just proving four implications!\u003cbr\u003e\u003cbr\u003eI have been given some similar tasks, and have already started proving some implications. Now I wonder, how many more implications do I have to prove? Can you help me determine this? \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"On the first line one positive number: the number of testcases, at most 100. After that per testcase:\u003cbr\u003e\u003cbr\u003e * One line containing two integers n (1 ≤ n ≤ 20000) and m (0 ≤ m ≤ 50000): the number of statements and the number of implications that have already been proved.\u003cbr\u003e * m lines with two integers s1 and s2 (1 ≤ s1, s2 ≤ n and s1 ≠ s2) each, indicating that it has been proved that statement s1 implies statement s2. "}},{"title":"Output","value":{"format":"HTML","content":"Per testcase:\u003cbr\u003e\u003cbr\u003e * One line with the minimum number of additional implications that need to be proved in order to prove that all statements are equivalent. "}},{"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 0\r\n3 2\r\n1 2\r\n1 3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}