{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003e在一些社交网络中,有 n 个用户在 m 组朋友圈中相互通信,让我们分析一下用户间信息传播的过程。\u003c/p\u003e\n\u003cp\u003e一开始,x 个用户从一些渠道获取到信息,然后他把这条信息发给他的朋友(如果两个用户同在一个或多组朋友圈里面,他们就算是朋友)。朋友们又会把信息发送给他们的朋友,以此类推。 当没有一对像这样的朋友时(其中一个知道这条信息而另一个不知道这条信息),传播过程就结束了。\u003c/p\u003e\n\u003cp\u003e对于每一个用户 x ,如果最初只有用户x开始发布消息,那么你需要输出知道该消息的用户数。 \u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含 2 个整数 n 和 m (1≤n,m≤5⋅10\u003csup\u003e5\u003c/sup\u003e) —— 分别代表用户数量以及朋友圈的数量。\u003c/p\u003e\n\u003cp\u003e接下来的 m 行输入,每行描述了一组朋友圈。第 i 行输入包含整数 k\u003csub\u003ei\u003c/sub\u003e (0≤k\u003csub\u003ei\u003c/sub\u003e≤n) —— 代表第 i 组朋友圈的用户数。接下来的 k\u003csub\u003ei\u003c/sub\u003e个整数代表了属于第 i 组朋友圈的用户的编号。\u003c/p\u003e\n\u003cp\u003e保证\n\u003cpre\u003e\nm\n\u003cfont size\u003d6\u003e∑\u003c/font\u003e k\u003csub\u003ei\u003c/sub\u003e ≤ 5⋅10\u003csup\u003e5\u003c/sup\u003e\n\u003csup\u003ei\u003d1\u003c/sup\u003e\n\u003c/pre\u003e\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e输出 n 个整数。第 i 个整数为编号为 i 的用户作为信息源所能传播的用户数。\u003c/p\u003e"}},{"title":"样例","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n 输入\n \u003c/div\u003e\n \u003cpre\u003e7 5\n3 2 5 4\n0\n2 1 2\n1 1\n2 6 7\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n 输出\n \u003c/div\u003e\n \u003cpre\u003e4 4 1 4 4 2 2 \u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}}]}