{"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\"\u003ethere are N ACMers in HDU team.\u003cbr\u003e ZJPCPC Sunny Cup 2007 is coming, and lcy want to select some excellent ACMers to attend the contest. There have been M matches since the last few days(No two ACMers will meet each other at two matches, means between two ACMers there will be at most one match). lcy also asks\"Who is the winner between A and B?\" But sometimes you can\u0027t answer lcy\u0027s query, for example, there are 3 people, named A, B, C.and 1 match was held between A and B, in the match A is the winner, then if lcy asks \"Who is the winner between A and B\", of course you can answer \"A\", but if lcy ask \"Who is the winner between A and C\", you can\u0027t tell him the answer.\u003cbr\u003e As lcy\u0027s assistant, you want to know how many queries at most you can\u0027t tell lcy(ask A B, and ask B A is the same; and lcy won\u0027t ask the same question twice).\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains multiple test cases.\u003cbr\u003eThe first line has one integer,represent the number of test cases.\u003cbr\u003eEach case first contains two integers N and M(N , M \u0026lt;\u003d 500), N is the number of ACMers in HDU team, and M is the number of matchs have been held.The following M lines, each line means a match and it contains two integers A and B, means A wins the match between A and B.And we define that if A wins B, and B wins C, then A wins C."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a integer which represent the max possible number of queries that you can\u0027t tell lcy."}},{"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\u003e3\r\n3 3\r\n1 2\r\n1 3\r\n2 3\r\n3 2\r\n1 2\r\n2 3\r\n4 2\r\n1 2\r\n3 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n0\r\n4\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\u003ein the case3, if lcy ask (1 3 or 3 1) (1 4 or 4 1) (2 3 or 3 2) (2 4 or 4 2), then you can\u0027t tell him who is the winner.\u003cbr\u003e"}}]}