{"raw_statement":[{"iden":"problem statement","content":"We have a weighted tree with $N$ vertices. The $i$\\-th edge connects Vertex $u_i$ and Vertex $v_i$ bidirectionally and has a weight $w_i$.\nFor a pair of vertices $(x,y)$, let us define $\\text{dist}(x,y)$ as follows:\n\n*   the **XOR** of the weights of the edges in the shortest path from $x$ to $y$.\n\nFind $\\text{dist}(i,j)$ for every pair $(i,j)$ such that $1 \\leq i \\lt j \\leq N$, and print the sum of those values modulo $(10^9+7)$.\nWhat is $\\text{ XOR }$?The bitwise $\\mathrm{XOR}$ of integers $A$ and $B$, $A\\ \\mathrm{XOR}\\ B$, is defined as follows:\n\n*   When $A\\ \\mathrm{XOR}\\ B$ is written in base two, the digit in the $2^k$'s place ($k \\geq 0$) is $1$ if exactly one of $A$ and $B$ is $1$, and $0$ otherwise.\n\nFor example, we have $3\\ \\mathrm{XOR}\\ 5 = 6$ (in base two: $011\\ \\mathrm{XOR}\\ 101 = 110$)."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq u_i \\lt v_i \\leq N$\n*   $0 \\leq w_i \\lt 2^{60}$\n*   The given graph is a tree.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$u_1$ $v_1$ $w_1$\n$u_2$ $v_2$ $w_2$\n$\\vdots$\n$u_{N-1}$ $v_{N-1}$ $w_{N-1}$"},{"iden":"sample input 1","content":"3\n1 2 1\n1 3 3"},{"iden":"sample output 1","content":"6\n\nWe have $\\text{dist}(1,2)=1,$ $\\text{dist}(1,3)=3,$ and $\\text{dist}(2,3)=2$, for the sum of $6$."},{"iden":"sample input 2","content":"5\n3 5 2\n2 3 2\n1 5 1\n4 5 13"},{"iden":"sample output 2","content":"62"},{"iden":"sample input 3","content":"10\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"},{"iden":"sample output 3","content":"241240228\n\nPrint the sum modulo $(10^9+7)$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}