An undirected connected graph has n
nodes and m
edges, The i
-th edge’s length is 2i
. Each node i
has a value ai
, which is either 0
or 1
. You need to calculate:
∑i=1n∑j=1nd(i,j)×[ai=1∧aj=0]
d(i,j)
indicates the shortest distance between i
and j
. [ ]
is the Iverson bracket. ∧
indicates AND
.
Because the answer may be too large, please output the answer modulo 109+7
.