{"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":"\u003csection\u003e\n \u003cp\u003eAlex has a weighted tree with \u003cvar\u003e\\(N\\)\u003c/var\u003e vertices. The \u003cvar\u003e\\(i\\)\u003c/var\u003e-th edge connects Vertex \u003cvar\u003e\\(u_i\\)\u003c/var\u003e and Vertex \u003cvar\u003e\\(v_i\\)\u003c/var\u003e bidirectionally and has a weight \u003cvar\u003e\\(w_i\\)\u003c/var\u003e.\u003c/p\u003e\n \u003cp\u003eFor a pair of vertices \u003cvar\u003e\\((x,y)\\)\u003c/var\u003e, Alex defines \u003cvar\u003e\\(\\text{dist}(x,y)\\)\u003c/var\u003e as the \u003cstrong\u003eXOR\u003c/strong\u003e of the weights of the edges in the shortest path from \u003cvar\u003e\\(x\\)\u003c/var\u003e to \u003cvar\u003e\\(y\\)\u003c/var\u003e.\u003c/p\u003e\n \u003c/ul\u003e\n \u003cp\u003eFind \u003cvar\u003e\\(\\text{dist}(i,j)\\)\u003c/var\u003e for every pair \u003cvar\u003e\\((i,j)\\)\u003c/var\u003e such that \u003cvar\u003e\\(1 \\leq i \\lt j \\leq N\\)\u003c/var\u003e, and print the sum of those values modulo \u003cvar\u003e\\((10^9+7)\\)\u003c/var\u003e.\u003c/p\u003e\n\u003c/section\u003e"}},{"title":"Constraints","value":{"format":"HTML","content":"\u003csection\u003e\n \u003cul\u003e\n \u003cli\u003e\u003cvar\u003e\\(2 \\leq N \\leq 2 \\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\n \u003cli\u003e\u003cvar\u003e\\(1 \\leq u_i \\lt v_i \\leq N\\)\u003c/var\u003e\u003c/li\u003e\n \u003cli\u003e\u003cvar\u003e\\(0 \\leq w_i \\lt 2^{60}\\)\u003c/var\u003e\u003c/li\u003e\n \u003cli\u003eThe given graph is a tree.\u003c/li\u003e\n \u003cli\u003eAll values in input are integers.\u003c/li\u003e\n \u003c/ul\u003e\n\u003c/section\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\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\n\u003cvar\u003e\\(u_1\\)\u003c/var\u003e \u003cvar\u003e\\(v_1\\)\u003c/var\u003e \u003cvar\u003e\\(w_1\\)\u003c/var\u003e\n\u003cvar\u003e\\(u_2\\)\u003c/var\u003e \u003cvar\u003e\\(v_2\\)\u003c/var\u003e \u003cvar\u003e\\(w_2\\)\u003c/var\u003e\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\n\u003cvar\u003e\\(u_{N-1}\\)\u003c/var\u003e \u003cvar\u003e\\(v_{N-1}\\)\u003c/var\u003e \u003cvar\u003e\\(w_{N-1}\\)\u003c/var\u003e\n\u003c/pre\u003e\n\u003c/section\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003csection\u003e\n \u003cp\u003ePrint the sum of \u003cvar\u003e\\(\\text{dist}(i,j)\\)\u003c/var\u003e, modulo \u003cvar\u003e\\((10^9+7)\\)\u003c/var\u003e.\u003c/p\u003e\n\u003c/section\u003e"}},{"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\u003e3\n1 2 1\n1 3 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003csection\u003e\n\u003c/section\u003e\u003csection\u003e\n \u003cp\u003eWe have \u003cvar\u003e\\(\\text{dist}(1,2)\u003d1,\\)\u003c/var\u003e \u003cvar\u003e\\(\\text{dist}(1,3)\u003d3,\\)\u003c/var\u003e and \u003cvar\u003e\\(\\text{dist}(2,3)\u003d2\\)\u003c/var\u003e, for the sum of \u003cvar\u003e\\(6\\)\u003c/var\u003e.\u003c/p\u003e\n\u003c/section\u003e"}},{"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\u003e5\n3 5 2\n2 3 2\n1 5 1\n4 5 13\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e62\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003csection\u003e\n\u003c/section\u003e\u003csection\u003e\n\u003c/section\u003e"}},{"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\u003e10\n5 7 459221860242673109\n6 8 248001948488076933\n3 5 371922579800289138\n2 5 773108338386747788\n6 10 181747352791505823\n1 3 803225386673329326\n7 8 139939802736535485\n9 10 657980865814127926\n2 4 146378247587539124\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e241240228\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003csection\u003e\n\u003c/section\u003e\u003csection\u003e\n \u003cp\u003ePrint the sum modulo \u003cvar\u003e\\((10^9+7)\\)\u003c/var\u003e.\u003c/p\u003e\n\u003c/section\u003e"}}]}