Alice recently find cactus grow near house after month cactus appear soon block road so Alice want clear thema cactus connect undirected graph no edge graph lie simple cycle Lets sequence different node graph x_1 x_2 ldot x_k simple cycle k geq 3 pair node x_1 x_2 x_2 x_3 ldot x_k1 x_k x_k x_1 connect edge Edges x_1 x_2 x_2 x_3 ldot x_k1 x_k x_k x_1 lie simple cycleThere cactus hard destroy but Alice magic when use magic node cactus remove independently probability frac12 when node remove edge connect removedNow Alice want test magic she pick cactus n node m edge let XS S subset remove node number connect component remain graph remove node set S before use magic wants know variance random variable x node graph probability frac12 remove n event independent by definition variance equal EX EX2 EX expect value x help calculate value modulo 1097formally let M 109 7 prime number it show answer express irreducible fraction fracpq p q integer q equiv 0 pmodM output integer equal p cdot q1 bmod M in word find integer x 0 le x M x cdot q equiv p pmodM