{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\n\u003csection\u003e\n\u003cp\u003eThere are \u003cvar\u003e\\(N\\)\u003c/var\u003e islands and \u003cvar\u003e\\(M\\)\u003c/var\u003e bridges.\u003c/p\u003e\n\u003cp\u003eThe \u003cvar\u003e\\(i\\)\u003c/var\u003e-th bridge connects the \u003cvar\u003e\\(A_i\\)\u003c/var\u003e-th and \u003cvar\u003e\\(B_i\\)\u003c/var\u003e-th islands bidirectionally.\u003c/p\u003e\n\u003cp\u003eInitially, we can travel between any two islands using some of these bridges.\u003c/p\u003e\n\u003cp\u003eHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the \u003cvar\u003e\\(M\\)\u003c/var\u003e-th bridge.\u003c/p\u003e\n\u003cp\u003eLet the \u003cstrong\u003edamage\u003c/strong\u003e be the number of pairs of islands \u003cvar\u003e\\((a, b)\\)\u003c/var\u003e (\u003cvar\u003e\\(a \u0026lt; b\\)\u003c/var\u003e) such that we are no longer able to travel between the \u003cvar\u003e\\(a\\)\u003c/var\u003e-th and \u003cvar\u003e\\(b\\)\u003c/var\u003e-th islands using some of the bridges remaining.\u003c/p\u003e\n\u003cp\u003eFor each \u003cvar\u003e\\(i\\)\u003c/var\u003e \u003cvar\u003e\\((1 \\leq i \\leq M)\\)\u003c/var\u003e, find the damage just after the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th bridge collapses.\u003c/p\u003e\n\u003c/section\u003e\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\n\u003csection\u003e\n\u003cul\u003e\n\u003cli\u003eAll values in input are integers.\u003c/li\u003e\n\u003cli\u003e\u003cvar\u003e\\(2 \\leq N \\leq 10^5\\)\u003c/var\u003e\u003c/li\u003e\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq M \\leq 10^5\\)\u003c/var\u003e\u003c/li\u003e\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq A_i \u0026lt; B_i \\leq N\\)\u003c/var\u003e\u003c/li\u003e\n\u003cli\u003eAll pairs \u003cvar\u003e\\((A_i, B_i)\\)\u003c/var\u003e are distinct.\u003c/li\u003e\n\u003cli\u003eThe damage is initially \u003cvar\u003e\\(0\\)\u003c/var\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/section\u003e\n"}},{"title":"Input","value":{"format":"HTML","content":"\n\u003csection\u003e\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e \u003cvar\u003e\\(M\\)\u003c/var\u003e\n\u003cvar\u003e\\(A_1\\)\u003c/var\u003e \u003cvar\u003e\\(B_1\\)\u003c/var\u003e\n\u003cvar\u003e\\(A_2\\)\u003c/var\u003e \u003cvar\u003e\\(B_2\\)\u003c/var\u003e\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\n\u003cvar\u003e\\(A_M\\)\u003c/var\u003e \u003cvar\u003e\\(B_M\\)\u003c/var\u003e\n\u003c/pre\u003e\n\n\u003c/section\u003e\n"}},{"title":"Output","value":{"format":"HTML","content":"\n\u003csection\u003e\n\u003cp\u003eIn the order \u003cvar\u003e\\(i \u003d 1, 2, ..., M\\)\u003c/var\u003e, print the damage just after the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th bridge collapses.\nNote that the answer may not fit into a \u003cvar\u003e\\(32\\)\u003c/var\u003e-bit integer type.\u003c/p\u003e\n\u003c/section\u003e\n"}},{"title":"Sample 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\u003e4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n0\n4\n5\n6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003csection\u003e\n\n\n\u003c/section\u003e\n\n\u003csection\u003e\n\n\n\u003cp\u003eFor example, when the first to third bridges have collapsed, the damage is \u003cvar\u003e\\(4\\)\u003c/var\u003e since we can no longer travel between the pairs \u003cvar\u003e\\((1, 2), (1, 3), (2, 4)\\)\u003c/var\u003e and \u003cvar\u003e\\((3, 4)\\)\u003c/var\u003e.\u003c/p\u003e\n\u003c/section\u003e\n"}},{"title":"Sample 2","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\u003e6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\n9\n12\n14\n15\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003csection\u003e\n\n\n\u003c/section\u003e\n\n\u003csection\u003e\n\n\n\u003c/section\u003e\n"}},{"title":"Sample 3","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 1\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003csection\u003e\n\n\n\u003c/section\u003e\n\n\u003csection\u003e\n\u003c/section\u003e\n"}}]}