{"trustable":false,"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n there are N ACMers in HDU team. \n \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. \n \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). \n\u003c/div\u003e\n题意:对于n个选手给出m场比赛的结果,结果有传递性(A战胜B ,B战胜C,则A可以战胜C),问有多少对选手不能判断他们之间的胜负关系"}},{"title":"Input","value":{"format":"HTML","content":"The input contains multiple test cases. \n\u003cbr\u003eThe first line has one integer,represent the number of test cases. \n\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 Input","value":{"format":"HTML","content":"\u003cpre\u003e3\n3 3\n1 2\n1 3\n2 3\n3 2\n1 2\n2 3\n4 2\n1 2\n3 4\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e0\n0\n4\n\n\n \n \u003ci style\u003d\"font-size:1px\"\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\nin 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.\n\n \n \u003c/pre\u003e"}}]}