{"trustable":true,"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":"\u003cp\u003e在某个社交网络中,有$$$n$$$个用户在$$$m$$$个朋友圈中相互通信。让我们分析在用户之间传播消息的过程。\u003c/p\u003e\u003cp\u003e最初,某个用户$$$x$$$从某个消息源接收到消息。然后他或她将消息发送给他或她的朋友(如果至少有一个朋友圈,使得他们两个都属于这个朋友圈,则两个用户是朋友)。朋友继续将消息传递给他们的朋友,依此类推。当没有一对朋友,其中一个知道消息,另一个不知道消息时,传播过程结束。\u003c/p\u003e\u003cp\u003e对于每个用户$$$x$$$,你需要确定如果最初只有用户$$$x$$$开始传播消息,那么知道消息的用户数量是多少。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含两个整数$$$n$$$和$$$m$$$($$$1 \\le n, m \\le 5 \\cdot 10^5$$$)— 用户数量和朋友圈数量。\u003c/p\u003e\u003cp\u003e接下来有$$$m$$$行,每行描述一个朋友圈。第$$$i$$$行以整数$$$k_i$$$($$$0 \\le k_i \\le n$$$)开始,表示第$$$i$$$个朋友圈中的用户数量。然后有$$$k_i$$$个\u003cspan class\u003d\"tex-font-style-bf\"\u003e不同的\u003c/span\u003e整数,表示属于第$$$i$$$个朋友圈的用户。\u003c/p\u003e\u003cp\u003e保证$$$\\sum \\limits_{i \u003d 1}^{m} k_i \\le 5 \\cdot 10^5$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e输出$$$n$$$个整数。第$$$i$$$个整数应该等于如果用户$$$i$$$开始传播消息,那么知道消息的用户数量。\u003c/p\u003e"}},{"title":"示例1","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\u003e7 5\n3 2 5 4\n0\n2 1 2\n1 1\n2 6 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 4 1 4 4 2 2 \u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}