Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the holeyness of S be the number of white vertices contained in S. Find the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as described in Notes.

-----Notes-----
When you print a rational number, first write it as a fraction \frac{y}{x}, where x, y are integers, and x is not divisible by 10^9 + 7
(under the constraints of the problem, such representation is always possible).
Then, you need to print the only integer z between 0 and 10^9 + 6, inclusive, that satisfies xz \equiv y \pmod{10^9 + 7}.

-----Constraints-----
 - 2 \leq N \leq 2 \times 10^5
 - 1 \leq A_i,B_i \leq N
 - The given graph is a tree.

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1}

-----Output-----
Print the expected holeyness of S, \bmod 10^9+7.

-----Sample Input-----
3
1 2
2 3

-----Sample Output-----
125000001

If the vertices 1, 2, 3 are painted black, white, black, respectively, the holeyness of S is 1.
Otherwise, the holeyness is 0, so the expected holeyness is 1/8.
Since 8 \times 125000001 \equiv 1 \pmod{10^9+7}, we should print 125000001.

Difficulty: interview

Starter code:

Solutions:
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


MOD = 1000000007
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

pow2 = [1] * (N + 1)
for i in range(N):
    pow2[i + 1] = pow2[i] * 2 % MOD

order = []
parent = [-1] * N

stack = deque([0])
while stack:
    v = stack.pop()
    order.append(v)
    for nv in G[v]:
        if parent[v] != nv:
            parent[nv] = v
            stack.append(nv)

numer = 0
nums = [0] * N

for v in reversed(order):
    tmp = 1
    for nv in G[v]:
        if parent[v] != nv:
            nums[v] += nums[nv] + 1
            tmp += pow2[nums[nv] + 1] - 1
    tmp += pow2[N - nums[v] - 1] - 1
    numer = (numer + pow2[N - 1] - tmp) % MOD

denom = pow2[N]
ans = numer * pow(denom, MOD - 2, MOD) % MOD
print(ans)


from sys import stdin
f_i = stdin

N = int(f_i.readline())

adj = [[] for i in range(N)]
for i in range(N - 1):
    A, B = map(int, f_i.readline().split())
    A -= 1
    B -= 1
    adj[A].append(B)
    adj[B].append(A)

mod = 10 ** 9 + 7

pow2 = [1] * (N + 1)
for i, j in zip(range(N), range(1, N + 1)):
    pow2[j] = pow2[i] * 2 % mod

from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

ans = 0

def dfs(node, parent):
    nonlocal ans
    cnt = 1
    
    for child in adj[node]:
        if child != parent:
            cnt += dfs(child, node)
    
    ans += (pow2[cnt] - 1) * (pow2[N-cnt] - 1)
    ans %= mod
    
    return cnt

dfs(0, None)

ans = (ans - N * pow2[N-1] + pow2[N] - 1) % mod
ans = ans * pow(pow2[N], mod - 2, mod) % mod

print(ans)

from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

pow2 = [1] * (N + 1)
for i in range(N):
    pow2[i + 1] = pow2[i] * 2 % MOD

order = []
parent = [-1] * N

stack = deque([0])
while stack:
    v = stack.pop()
    order.append(v)
    for nv in G[v]:
        if parent[v] != nv:
            parent[nv] = v
            stack.append(nv)

numer = 0
nums = [0] * N

for v in reversed(order):
    tmp = 1
    for nv in G[v]:
        if parent[v] != nv:
            nums[v] += nums[nv] + 1
            tmp += pow2[nums[nv] + 1] - 1
    tmp += pow2[N - nums[v] - 1] - 1
    numer = (numer + pow2[N - 1] - tmp) % MOD

denom = pow2[N]
ans = numer * pow(denom, MOD - 2, MOD) % MOD
print(ans)


import sys
sys.setrecursionlimit(10**6)
mod = 10**9+7
p2 = [1]*(3*10**5)
for n in range(3*10**5-1):
    p2[n+1] = p2[n]*2%mod

N = int(input())
AB = [list(map(int,input().split())) for _ in range(N-1)]
g = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = AB[i]
    g[a].append(b)
    g[b].append(a)

l1 = [0]*(N+1)
l2 = [[] for _ in range(N+1)]

def rec(p,c):
    res = 0
    for a in g[c]:
        if a == p:
            continue
        n = rec(c,a)
        l2[c].append(n+1)
        res += n+1
    l1[c] = res
    return res

n = rec(0,1)
for i in range(1,N+1):
    l2[i].append(N-1-l1[i])

ans = 0
for i in range(1,N+1):
    ans += p2[N-1]-1
    ans %= mod
    for j in l2[i]:
        ans -= p2[j]-1
        ans %= mod
ans *= pow(p2[N],mod-2,mod)
ans %= mod
print(ans)


# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())
#n = [int(i) for i in readline().split()]
 
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)
 

#from collections import deque

cnt = [-1]*n
parent = [-1]*n

q = [0]
order = []
while q:
    v = q.pop()
    order.append(v)
    for c in g[v]:
        if parent[v] != c:
            parent[c] = v
            q.append(c)

MOD = 10**9+7

pow2 = [1]
for i in range(n):
    pow2.append(pow2[-1]*2%MOD)


num = [0]*n
ans = 0
for v in reversed(order):
    res = 1
    nokori = n-1
    for c in g[v]:
        if c != parent[v]:
            nc = num[c]+1
            res += pow2[nc] - 1
            num[v] += nc
            nokori -= nc
            #print(c,v,nc)
    res += pow2[nokori] - 1
    #print(res,nokori)
    ans += pow2[n-1]-res 

#print(parent)
#print(num)
#print(pow2)

R = (MOD+1)//2

print((ans*pow(R,n,MOD)%MOD))


            
            
        
    
    






import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n=int(input())
edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
inf=10**6
Par=[inf]*n
Par[0]=-1
Deg=[0]*n
Deg[0]=0
Chk=[0]
while Chk:
  c=Chk.pop()
  for next in edge[c]:
    if Par[next]==inf:
      Par[next]=c
      Deg[next]+=1
      Chk.append(next)

from collections import deque
TS=list(v for v in range(n) if Deg[v]==0)
D=deque(TS)
while D:
  v=D.popleft()
  for t in edge[v]:
    if t!=Par[v]:
      Deg[t]-=1
      if Deg[t]==0:
        D.append(t)
        TS.append(t)

Used=[False]*n
C=[0]*n
for i in reversed(list(range(n))):
  v=TS[i]
  Used[v]=True
  for g in edge[v]:
    if not Used[g]:
      C[g]+=C[v]+1

H=[0]*n
H[0]=1
H[1]=pow(2,mod-2,mod)
for i in range(2,n):
  H[i]=(H[i-1]*H[1])%mod

ans=0
for i in range(n):
  if len(edge[i])==1:
    continue
  else:
    A=[]
    for e in edge[i]:
      if e==Par[i]:
        A.append(n-1-C[i])
      else:
        A.append(C[e]+1)
    cur=1+(len(edge[i])-1)*H[-1]
    for a in A:
      cur-=H[n-1-a]
    ans=(ans+cur)%mod
print(((ans*H[1])%mod))


n=int(input())
mod=10**9+7
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)

inv2=[1]*(n+1)
t=pow(pow(2,n,mod),mod-2,mod)
for i in range(n,-1,-1):
    inv2[i]=t
    t*=2
    t%=mod
    
import sys
sys.setrecursionlimit(10**6)
dep=[-1 for i in range(n+1)]
ans=[0]
def f(a):
    return inv2[n-a]*(1-inv2[a])%mod
def dfs(s,d):
    dep[s]=d
    tmp=inv2[1]-inv2[n]
    y=0
    for i in edge[s]:
        if dep[i]==-1:
            x=dfs(i,d+1)
            tmp-=f(x)
            y+=x
    if y==0:
        return 1
    tmp-=f(n-y-1)
    ans[0]+=tmp
    ans[0]%=mod
    return y+1
dfs(1,0)
print(ans[0])

#f
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)
 

n = int(input())
E = [[] for _ in range(n)]
mod = 10**9 + 7

for i in range(n-1):
    a,b = [int(x) for x in input().split()]
    E[a-1].append((b-1, i)) 
    E[b-1].append((a-1, i)) 
    
X = [0] * n
    
def dfs(u,e):
    num = 1
    for v,c in E[u]:
        if c != e:
            num += dfs(v,c)
    X[e] = num 
    return num

dfs(0, -1)

I = [1]
inv = pow(2, mod-2, mod)
for i in range(n):
    I.append(I[-1] * inv % mod)

ans = 0
for i in range(n):
    x = X[i]
    ans += (1-I[x])*(1-I[n-x]) % mod
    
ans -= n * I[1]
ans += 1 - I[n]
ans %= mod
print(ans)



import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
g = [[] for _ in range(n)]

pow2 = [0 for _ in range(n+1)]
pow2[0] = 1
for i in range(n):
    pow2[i+1] = pow2[i]*2 %mod

for _ in range(n-1):
    a,b = list(map(int, input().split()))
    g[a-1].append(b-1)
    g[b-1].append(a-1)

depth = [-1]*n
ko_all = [0 for _ in range(n)]
ko_only =[0 for _ in range(n)]

def dfs(v,d):
    depth[v] = d
    for w in g[v]:
        if depth[w] == -1:
            dfs(w,d+1)
            ko_all[v] += ko_all[w]+1
            ko_only[v] += pow2[ko_all[w]+1]-1

dfs(0,0)

cnt = 0

for i in range(n):
    tmp = pow2[n-1]-1-(pow2[n-1-ko_all[i]]-1) - ko_only[i]
    tmp %=mod
    cnt += tmp
    cnt %= mod

def inv(a,mod):
    r = [1,0,a]
    w = [0,1,mod]
    while w[2]!=1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = w
        w = r_new
    x,y = w[0],w[1]    # a*x+y*mod = 1
    return (mod+x%mod)%mod

print((inv(pow2[n],mod)*cnt %mod))


import sys
sys.setrecursionlimit(200200)
input = sys.stdin.readline
MOD=10**9+7
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N-1)]
G = [[] for _ in range(N)]
for i, (a, b) in enumerate(AB):
    a -= 1
    b -= 1
    G[a].append((b, i))
    G[b].append((a, i))

P = [0] * N
visited = [False] * N
visited[0] = True
def dfs(x, i):
    e = 1
    for v, c in G[x]:
        if not visited[v]:
            visited[v] = True
            e += dfs(v, c)
    P[i] = e
    return e

dfs(0, -1)
W = [1] * (N + 1)
inv_2 = pow(2, MOD-2, MOD)
for i in range(N):
    W[i+1] = W[i]*inv_2%MOD
ans = (W[N] + 1) * (N - 1) % MOD
for i in range(N-1):
    ans -= W[P[i]] + W[N-P[i]]
    ans %= MOD
print((ans - inv_2*N - W[N] + 1) % MOD)

from collections import defaultdict
import sys


sys.setrecursionlimit(10 ** 6)


def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    adj = defaultdict(list)
    for _ in range(N - 1):
        A, B = list(map(lambda x: int(x) - 1, input().split()))
        adj[A].append(B)
        adj[B].append(A)

    # 2 ** n の事前計算
    pow_2 = [1 for _ in range(N + 1)]
    for i in range(1, N + 1):
        pow_2[i] = pow_2[i - 1] * 2 % MOD

    # 分子：sum_{i} (node i が穴あき度の値としてカウント対象になるような塗り方)
    # node_num[(node, dir_node)]: nodeから見てdir_node方向に存在するノードの数
    #         5               6
    #        (6)             (6)
    #         |               |
    #        (1)             (1)
    # 0(6)-(1)1(4)-(3)2(3)-(4)3(1)-(6)4
    node_num = defaultdict(int)

    def dfs(node=0, parent=None):
        child_list = [n for n in adj[node] if n != parent]
        if len(child_list) == 0:
            node_num[(node, parent)] = N - 1
            node_num[(parent, node)] = 1
            return 1
        n_descendant = 1  # self
        for child in child_list:
            n_descendant += dfs(child, node)
        if parent is not None:
            node_num[(node, parent)] = N - n_descendant
            node_num[(parent, node)] = n_descendant
        return n_descendant

    dfs()

    numer = 0
    for node in range(N):
        if len(adj[node]) <= 1:
            # 端（次数1）のノードはカウント対象にならない
            continue
        cnt_not = 0  # node が穴あき度の値としてカウントされないケース
        for dir_node in adj[node]:
            # dir_node方向のノードは自由、それ以外の方向のノードは全部白
            cnt_not += pow_2[node_num[(node, dir_node)]]
        cnt_not -= len(adj[node]) - 1  # 「全部白塗り」の重複カウントを除去
        numer += pow_2[N - 1] - cnt_not  # node自身は白でないとカウントされないので、全体のパターン数が2 ** (N-1)

    # 分母：2 ** N （全部の塗り方）
    denom = pow_2[N]

    # 答え
    print(numer * mod_inv(denom, MOD) % MOD)


def __starting_point():
    main()
__starting_point()

import sys

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))


n = ni()
G = [list() for _ in range(n)]
for _ in range(n-1):
  a, b = nm()
  a -= 1; b -= 1
  G[a].append(b)
  G[b].append(a)
  
  
mod = 10**9 + 7
dub = [1]*(n+1)
for i in range(n):
  dub[i+1] = dub[i] * 2
  if dub[i+1] > mod:
    dub[i+1] -= mod
    
size = [-1]*n
q = [0]
while q:
  v = q[-1]
  if size[v] < 0:
    for x in G[v]:
      if size[x] < 0:
        q.append(x)
    size[v] = 0
  else:
    size[v] = 1
    for x in G[v]:
      size[v] += size[x]
    q.pop()

ans = 0
for v in range(n):
  c = 0
  res = 1
  for x in G[v]:
    if size[x] < size[v]:
      c += size[x]
      res += dub[size[x]] - 1
  res += dub[n-1-c] - 1
  res %= mod
  ans = (ans + dub[n-1] - res) % mod
print(ans * pow(dub[n], mod-2, mod) % mod)

import sys
sys.setrecursionlimit(200200)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, i):
    res = 1
    for v, c in E[u]:
        if i != c:
            res += dfs(v, c)
    X[i] = res
    return res

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = (I[N] + 1) * (N - 1) - inv * N - I[N] + 1
for e in range(N - 1):
    ans -= I[X[e]] + I[N - X[e]]
    ans %= mod

print(ans)

#f
#change the limit of how much depth of recursive func is available. 
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)
 

n = int(input())
E = [[] for _ in range(n)]
mod = 10**9 + 7

for i in range(n-1):
    a,b = [int(x) for x in input().split()]
    E[a-1].append((b-1, i)) 
    E[b-1].append((a-1, i)) 
    
X = [0] * n
    
def dfs(u,e):
    num = 1
    for v,c in E[u]:
        if c != e:
            num += dfs(v,c)
    X[e] = num 
    return num

dfs(0, -1)

I = [1]
inv = pow(2, mod-2, mod)
for i in range(n):
    I.append(I[-1] * inv % mod)

ans = 0
for i in range(n):
    x = X[i]
    ans += (1-I[x])*(1-I[n-x]) % mod
    
ans -= n * I[1]
ans += 1 - I[n]
ans %= mod
print(ans)



import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
n = int(input())
edges = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, i))
    edges[b - 1].append((a - 1, i))
l = [0 for i in range(n)]
def dfs(cur, x):
    res = 1
    for i in edges[cur]:
        if i[1] != x:
            res += dfs(i[0], i[1])
    l[x] = res
    return res
dfs(0, -1)
l2 = [1]
i2 = pow(2, mod - 2, mod)
for i in range(n):
    l2.append(l2[-1] * i2 % mod)
cnt = 0
for i in l:
    cnt += (1 - l2[i]) * (1 - l2[n - i])
print((-n * i2 - l2[-1] + cnt + 1) % mod)

# classを使うのをやめてlistで実施する
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

def dfs(v):
    visited[v] = True
    for i in range(len(AL[v][CHILDREN])):
        u = AL[v][CHILDREN][i]
        if visited[u]:
            AL[v][CHILDREN][i] = None
            continue
        AL[v][SIZE] += dfs(u)
    return AL[v][SIZE]

def anaaki(v):
    ret = powp - 1
    for ch in AL[v][CHILDREN]:
        if ch is None: continue
        ret -= pow(2, AL[ch][SIZE], p) - 1
        ret %= p
    ret -= pow(2, n - AL[v][SIZE], p) - 1
    ret %= p
    return ret

n = int(input())
SIZE = 0
CHILDREN = 1
AL = [[1, []] for _ in range(n)]
visited = [False] * n
p = 10 ** 9 + 7
powp = pow(2, n - 1, p)

for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    AL[a][CHILDREN].append(b)
    AL[b][CHILDREN].append(a)

dfs(0)
numer = 0
for i in range(n):
    numer += anaaki(i)
    numer %= p

denom = powp * 2 % p
print(numer * pow(denom, p - 2, p) % p)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

def solve():
    N = int(input())
    AB = [tuple(map(int,input().split())) for i in range(N-1)]
    MOD = 10**9+7
    es = [[] for _ in range(N)]
    for a,b in AB:
        a,b = a-1,b-1
        es[a].append(b)
        es[b].append(a)

    cs = [1] * N
    def dfs(v,p=-1):
        ret = 1
        for to in es[v]:
            if to==p: continue
            ret += dfs(to,v)
        cs[v] = ret
        return ret
    dfs(0)

    pow2 = [1]
    for i in range(N):
        pow2.append((pow2[-1]*2) % MOD)

    ans = 0
    for i in range(N):
        if len(es[i]) == 1: continue
        ans += pow2[N-1] - 1
        c = 0
        for to in es[i]:
            if cs[to] > cs[i]: continue
            c += cs[to]
            ans -= pow2[cs[to]] - 1
        ans -= pow2[N-c-1] - 1

    ans *= pow(pow2[N], MOD-2, MOD)
    print(ans%MOD)
solve()

from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

pow2 = [1] * (N + 1)
for i in range(N):
    pow2[i + 1] = pow2[i] * 2 % MOD

order = []
parent = [-1] * N

stack = deque([0])
while stack:
    v = stack.pop()
    order.append(v)
    for nv in G[v]:
        if parent[v] != nv:
            parent[nv] = v
            stack.append(nv)

numer = 0
nums = [0] * N

for v in reversed(order):
    tmp = 1
    for nv in G[v]:
        if parent[v] != nv:
            c = nums[nv] + 1
            nums[v] += c
            tmp += pow2[c] - 1
    tmp += pow2[N - nums[v] - 1] - 1
    numer = (numer + pow2[N - 1] - tmp) % MOD

denom = pow2[N]
ans = numer * pow(denom, MOD - 2, MOD) % MOD
print(ans)


#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(item) - 1 for item in input().split()]
    edge[a].append(b)
    edge[b].append(a)

childs = [[] for _ in range(n)]
def dfs(p, v):
    val = 1
    for nv in edge[v]:
        if nv == p:
            continue
        ret = dfs(v, nv)
        val += ret
        childs[v].append(ret)
    if val != n:
        childs[v].append(n - val)
    return val

dfs(-1, 0)
total_pattern = pow(2, n, MOD)
total_pattern_inv = pow(total_pattern, MOD-2, MOD)
inv2 = pow(2, MOD-2, MOD)
pow2_table = [1]
for i in range(2 * 10**5):
    pow2_table.append(pow2_table[-1] * 2 % MOD)
ans = 0
for line in childs:
    pattern_ok = 0
    if len(line) == 1:
        continue
    for item in line:
        pattern_ok += pow2_table[item] - 1
    pattern_ok += 1
    ans += (total_pattern * inv2 - pattern_ok) * total_pattern_inv
    ans %= MOD
print(ans)

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = [0]*n
    d[0] = 1
    q = deque([0])
    p = [None]*n
    while q:
        x = q.popleft()
        nd = d[x]+1
        for y in v[x]:
            if not d[y]:
                d[y] = nd
                p[y] = x
                q.append(y)
    V = list(range(n))
    V.sort(key = lambda x:-d[x])
    t = [1]*n
    for x in V[:-1]:
        t[p[x]] += t[x]
    ans = 0
    p = pow(2,n-1,mod)
    for x in range(n):
        tx = t[x]
        if len(v[x]) < 2:
            continue
        s = p-1
        for y in v[x]:
            ty = t[y]
            if tx < ty:
                s -= pow(2,t[0]-tx,mod)-1
            else:
                s -= pow(2,ty,mod)-1
            s %= mod
        ans += s
        ans %= mod
    print((ans*pow(2,(mod-2)*n%(mod-1),mod)%mod))
    return

#Solve
def __starting_point():
    solve()

__starting_point()

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

ans=0
def main(n,ab):
  ki=[[] for _ in range(n)]
  for a,b in ab:
    a,b=a-1,b-1
    ki[a].append(b)
    ki[b].append(a)
  mod=10**9+7
  n2=[1]
  for i in range(n):
    n2.append((n2[-1]*2)%mod)
  def dfs1(v,p):
    ret=0
    nonlocal ans
    ans+=n2[n-1]-1
    for nv in ki[v]:
      if nv==p:continue
      x=dfs1(nv,v)
      ans-=n2[x]-1
      ans-=n2[n-x]-1
      ret+=x
    ans%=mod
    return ret+1
  dfs1(0,-1)
  allpat=pow(2,n,mod)
  nonlocal ans
  ans*=pow(allpat,mod-2,mod)
  return ans%mod

n=int(input())
ab=[list(map(int,input().split())) for _ in range(n-1)]
print((main(n,ab)))



from sys import setrecursionlimit
setrecursionlimit(2 * (10 ** 5))

n = int(input())
ab = [tuple([int(x)-1 for x in input().split()]) for _ in range(n-1)]

e = [[] for _ in range(n)]

for a, b in ab:
    e[a].append(b)
    e[b].append(a)

MOD = 10 ** 9 + 7

d = []

def modinv(x):
    a = x
    b = MOD
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= MOD
    if u < 0:
        u += MOD
    return u

def dfs(x, p):
    if len(e[x]) == 1:
        if e[x][0] == p:
            d.append(1)
            return 1
    ret = 1
    for z in e[x]:
        if z == p:
            continue
        ret += dfs(z, x)
    if x != 0:
        #print(x, d)
        d.append(ret)
    return ret

dfs(0,-1)

f = []
w = 1
for i in range(n + 1):
    f.append(w)
    w = (w * 2) % MOD

#print(d)

ans = 0
for x in d:
    ans += ((f[x] - 1) * (f[n-x] - 1)) % MOD
    ans %= MOD

#print(ans)

ans = (ans - f[n-1] * n + f[n] - 1 + MOD) % MOD

#print(ans)

ans = (ans * modinv(f[n])) % MOD

print(ans)


import sys
sys.setrecursionlimit(10**7)
P=10**9+7
N=int(input())
edges = [[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    edges[a-1].append((b-1, i))
    edges[b-1].append((a-1, i))
L=[0 for i in range(N)]
def dfs(cur, x):
  res = 1
  for i in edges[cur]:
    if i[1]!=x:
      res += dfs(i[0], i[1])
  L[x]=res
  return res
dfs(0,-1)
L2=[1]
i2=pow(2,P-2,P)
for i in range(N):
  L2.append(L2[-1]*i2%P)
cnt = 0
for i in L:
  cnt+=(1-L2[i])* (1-L2[N-i])
print((-N*i2-L2[-1]+cnt+1)%P)

import sys
input = sys.stdin.readline

mod = 10**9+7

def dfs(graph, N):
    ans = 0
    Par = [-1]*N
    Childs = [[] for _ in range(N)]
    stack = [0]
    while stack:
        p = stack.pop()
        if p >= 0:
            stack.append(~p)
            for np in graph[p]:
                if np != 0 and Par[np] == -1:
                    stack.append(np)
                    Par[np] = p
        else:
            p = ~p
            score = pow(2, N-1, mod) - 1
            upper = N-1
            for a in Childs[p]:
                upper -= a
                score = (score - pow(2, a, mod) + 1) % mod
            if p != 0:
                score = (score - pow(2, upper, mod) + 1) % mod
            ans = (ans + score) % mod
            Childs[Par[p]].append(N-1-upper+1)
    
    return ans * pow(2, N*(mod-2), mod) % mod

def main():
    N = int(input())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    print(dfs(graph, N))


def __starting_point():
    main()
__starting_point()

#解説方針#解法1
#https://qiita.com/ZhangChaoran/items/71fab0e4b8647a93d3a0
from collections import deque
from heapq import heappop, heappush
#標準入力
N = int(input())
MOD = 10 ** 9 + 7
L = [[] for i in range(N + 1)] #dfs用
for i in range(N - 1):
  a, b = map(int, input().split())
  L[a].append(b)
  L[b].append(a)

#木の探索
parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  # 行きがけ順探索リスト
    for y in L[x]:
        if y == parent[x]:
            continue
        parent[y] = x  # 親ノードを記録
        stack.append(y)
#print(order, parent)

half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)#2 ** N の逆元の集合
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):#iが1から
    p = parent[v]
    x = size[v]  # vの子孫ノード数（自分も含む）をとる
    size[p] += x  # 親にノード数を加算
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]
#print(size)
# 辺iがSに含まれるための必要十分条件による辺の個数の期待値 
# (1 - (1/2) ** i)(1 - (1/2) ** (N - i))を展開して計算
# 根である1の頂点以外は、ある頂点とその親を結ぶ辺を考えた際
# i と N - i個の頂点に別れるので,size[2:]でOK
ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) %
          MOD for i in size[2:])  
#ans = sum((1 - (1/2) ** i- (1/2) ** (N - i) + (1/2) ** N) for i in size[2:])  
#print(ans)
ans += 1  # 木の頂点の個数は辺の個数+1
# -「すべての辺が含まれない、つまり空グラフの場合の誤加算」-N/2
ans -= power_inv[N] + N * power_inv[1]  
#ans -= N * power_inv[1]  
ans %= MOD

print(ans)

# ref https://qiita.com/ZhangChaoran/items/71fab0e4b8647a93d3a0
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
g = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a].append(b)
    g[b].append(a)

mod = 10**9 + 7
par = [0] * (n + 1)
order = []
stk = deque()
stk.append(1)

while stk:
    v = stk.pop()
    order.append(v)
    for x in g[v]:
        if x == par[v]:
            continue
        par[x] = v
        stk.append(x)

rev = pow(2, mod - 2, mod)
po2_inv = [1] * (n + 1)
size = [1] * (n + 1)
for i, y in enumerate(order[::-1], 1):
    p = par[y]
    size[p] += size[y]
    po2_inv[i] = po2_inv[i - 1] * rev % mod

ans = 1
for i in size[2:]:
    ans += (1 - po2_inv[i] - po2_inv[n - i] + po2_inv[n]) % mod
ans -= po2_inv[n] + n * po2_inv[1]
ans %= mod
print(ans)


import sys
input=lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(200000)
mod=10**9+7
n=int(input())
edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
inf=10**6
Par=[inf]*n
Par[0]=-1
Chk=[0]
while Chk:
  c=Chk.pop()
  for next in edge[c]:
    if Par[next]==inf:
      Par[next]=c
      Chk.append(next)

C=[-1]*n
def ch(x):
  ret=0
  if x!=0 and len(edge[x])==1:
    C[x]=0
    return C[x]
  else:
    for e in edge[x]:
      if e==Par[x]:
        continue
      else:
        ret+=ch(e)+1
    C[x]=ret
    return C[x]
ch(0)

H=[0]*n
H[0]=1
H[1]=pow(2,mod-2,mod)
for i in range(2,n):
  H[i]=(H[i-1]*H[1])%mod

ans=0
for i in range(n):
  if len(edge[i])==1:
    continue
  else:
    A=[]
    for e in edge[i]:
      if e==Par[i]:
        A.append(n-1-C[i])
      else:
        A.append(C[e]+1)
    cur=1+(len(edge[i])-1)*H[-1]
    for a in A:
      cur-=H[n-1-a]
    ans=(ans+cur)%mod
print((ans*H[1])%mod)

import sys


def dfs1(root, links):
    parent = [0] * n
    subtree_count = [{} for _ in range(n)]
    q = [(root, -1, 0)]  # 2番目:親  3番目:0=初, 1=全ての子巡回後
    while q:
        v, p, t = q.pop()
        if t == 0:
            parent[v] = p
            q.append((v, p, 1))
            for u in links[v]:
                if u == p:
                    continue
                q.append((u, v, 0))
        elif p != -1:
            subtree_count[p][v] = sum(subtree_count[v].values()) + 1
    return parent, subtree_count


def dfs2(root, parent, subtree_count, d2, d2s):
    ans = 0
    q = [(root, 0)]
    while q:
        v, pc = q.pop()

        if len(subtree_count[v]) == 0:
            continue

        p = parent[v]
        children, st_counts = list(map(list, list(zip(*list(subtree_count[v].items())))))
        children.append(p)
        st_counts.append(pc)
        cl = len(st_counts)
        ct = sum(st_counts)

        for u, stc in list(subtree_count[v].items()):
            q.append((u, ct - stc + 1))

        if cl == 1:
            continue

        tmp = 0
        for stc in st_counts:
            tmp = (tmp + d2s[ct - stc]) % MOD
        tmp = (tmp - d2s[ct] * (cl - 1)) % MOD
        ans = (ans + (1 - tmp) * d2) % MOD
    return ans


n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = list(map(int, line.split()))
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
root = 0
MOD = 10 ** 9 + 7
d2 = 500000004  # 2^-1 mod 10**9+7
d2s = [1]
for i in range(n):
    d2s.append(d2s[-1] * d2 % MOD)
parent, subtree_count = dfs1(root, links)
# print(parent)
# print(subtree_count)
ans = dfs2(root, parent, subtree_count, d2, d2s)
print(ans)


import sys
sys.setrecursionlimit(200200)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

visited = [False] * N
visited[0] = True

def dfs(u, i):
    res = 1
    for v, c in E[u]:
        if not visited[v]:
            visited[v] = True
            res += dfs(v, c)
    X[i] = res
    return res

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = (I[N] + 1) * (N - 1) - inv * N - I[N] + 1
for xe in range(N - 1):
    ans -= I[X[xe]] + I[N - X[xe]]
    ans %= mod

print(ans)

import sys
sys.setrecursionlimit(10 ** 6)

LI = lambda: list(map(int, input().split()))

N = int(input())
AB = [LI() for _ in range(N - 1)]

link = [[] for _ in range(N)]
children = [[] for _ in range(N)]
w = [1] * N
visit = [False] * N

MOD = 10 ** 9 + 7


def create_link():
    for a, b in AB:
        link[a - 1].append(b - 1)
        link[b - 1].append(a - 1)


def dfs(s):
    visit[s] = True
    for t in link[s]:
        if visit[t]:
            continue
        children[s].append(t)
        dfs(t)
        w[s] += w[t]


def modinv(x):
    return pow(x, MOD - 2, MOD)


def main():
    create_link()
    dfs(0)
    p2 = [None] * (N + 1)
    p2[0] = 1
    for i in range(N):
        p2[i + 1] = 2 * p2[i] % MOD
    
    x = 0
    for i in range(N):
        s = p2[N - w[i]]
        for j in children[i]:
            s = (s + p2[w[j]] - 1) % MOD
        x = (x + p2[N - 1] - s) % MOD
    y = p2[N]

    ans = x * modinv(y) % MOD
    print(ans)


def __starting_point():
    main()

__starting_point()

# Surrounded Nodes
from collections import deque
import sys
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
N = int(input())
G = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
S = -1
for i in range(1, N+1):
    if len(G[i]) == 1:
        S = i
        break
visited = [False for i in range(N+1)]
parent = [-1 for i in range(N+1)]
count = [1 for i in range(N+1)]

ans = N*pow(2, N-1, mod)
stack = deque()


def dfs(node):
    visited[node] = True
    for child in G[node]:
        if visited[child] == False:
            parent[child] = node
            stack.append((node, child))
            dfs(child)


powers = [1 for i in range(2*10**5+1)]
for i in range(1, 2*10**5+1):
    powers[i] = powers[i-1]*2 % mod

dfs(S)
while stack:
    mom, child = stack.pop()
    count[mom] += count[child]
ans = 0
for i in range(1, N+1):
    if len(G[i]) > 1:
        ans += powers[N-1]
        for x in G[i]:
            if x != parent[i]:
                ans -= powers[count[x]]
        ans -= powers[N-count[i]]
        ans += len(G[i]) - 1
        ans %= mod
D = pow(2, N, mod)
print(ans*pow(D, mod-2, mod) % mod)

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
G = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]


par = [-1] * n
cnt = [0] * n


def f(u):
    ret = 1
    for v in G[u]:
        if v == par[u]:
            continue
        par[v] = u
        ret += f(v)
    cnt[u] = ret
    return ret

f(0)
pow2 = [1] * (n + 1)
for i in range(1, n + 1):
    pow2[i] = pow2[i - 1] * 2 % mod

q = deque([0])
ans = 0
while q:
    u = q.pop()
    ret = pow2[n - 1] - 1
    for v in G[u]:
        if v == par[u]:
            continue
        ret -= pow2[cnt[v]] - 1
        q += [v]
    ret -= pow2[n - cnt[u]] - 1
    ans = (ans + ret) % mod

print((ans * pow(pow2[n], mod - 2, mod) % mod))






import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

mod = 10 ** 9 + 7

N = int(input())
vec = [[] for _ in range(N)]
for _ in range(N-1) :
  A, B = map(int, input().split())
  vec[A-1].append(B-1)
  vec[B-1].append(A-1)

sub_size = [[] for _ in range(N)]

def dfs(cur=0, pre=-1) :
  s = 0
  for nex in vec[cur] :
    if nex == pre :
      continue
    t = dfs(nex, cur)
    s += t
    sub_size[cur].append(t)
  if s != N - 1 :
    sub_size[cur].append(N - 1 - s)

  return s + 1

dfs()

power = [1]
for _ in range(N) :
  power.append(power[-1]*2%mod)

ret = 0
for i in range(N) :
  tmp = power[N-1]-1
  for ss in sub_size[i] :
    tmp -= power[ss]-1
  ret += tmp

ret = ret*pow(power[N], mod - 2, mod)% mod

print(ret)

import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N = int(input()); MOD=pow(10,9)+7

beki = [-1]*(N+1); beki[0] = 1; beki[1] = 2 #階乗
for i in range(2,N+1):
  beki[i] = beki[i-1]*2%MOD
#print(beki)

G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int,input().split()))
  a-=1;b-=1
  G[a].append(b);G[b].append(a)
#print(G)
ans = 0

def dfs(v,p): #自分と親
  nonlocal ans #ansをGlobal変数として宣言
  res = 1 #戻り値。vを含めた部分木のサイズ。自分の分で最初は1
  ts = [] #vから生えている部分木のリスト
  for u in G[v]:
    if u == p:
      continue
    t = dfs(u,v) #uの部分木のサイズが戻り値
    res += t
    ts.append(t)
  if p != -1: #根以外なら親側の部分木が存在する。
    ts.append(N-res)
  now = beki[N-1] - 1 #自分以外を決めるのが2^(N-1)通り。自分以外が全部0が1通り。
  for x in ts:
    now -= beki[x] - 1 #各部分木に一個以上黒がある場合の数。全通り - 全部白
  ans = (ans+now)%MOD
  return res #vを含めた部分木のサイズ

dfs(0,-1)
ALL = pow(2,N,MOD)
#print(ans,ALL)
ans = ans*pow(ALL,MOD-2,MOD)%MOD #フェルマーの小定理より1/ALL = ALL^(MOD-2)
print(ans)


import sys
sys.setrecursionlimit(10**9)
MOD=10**9+7
N=int(input())

tree=[[] for _ in range(N+1)]
for _ in range(N-1):
  A,B=map(int,input().split())
  tree[A].append(B)
  tree[B].append(A)
#print(tree)

def dfs(u,par):
  visited[u]=True
  ret=1
  for v in tree[u]:
    if not visited[v]:
      ret+=dfs(v,u)

  if par>0:
    tree_dic[(u,par)]=ret
  return ret
  
visited=[False]*(N+1)
tree_dic={}
dfs(1,0)
#print(tree_dic)

bumbo=pow(2,N,MOD)
bunshi=(pow(2,N,MOD)-1-N*pow(2,N-1,MOD))%MOD
for x in tree_dic.values():
  term=(pow(2,x,MOD)-1)*(pow(2,N-x,MOD)-1)
  bunshi+=term  
  bunshi%=MOD
#print(bunshi,bumbo)

answer=bunshi*pow(bumbo,MOD-2,MOD)
answer%=MOD
print(answer)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

mod = 10**9+7

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m=mod):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


N2 = [1]
n = 1
for _ in range(N+1):
    n = n*2 % mod
    N2.append(n)

Weight = [[] for _ in range(N)]
checked = [False]*N

def dfs(p):
    checked[p] = True
    downs = 0
    for np in graph[p]:
        if not checked[np]:
            downscore = dfs(np)
            Weight[p].append(N-downscore)
            Weight[np].append(downscore)
            downs += N-downscore
    
    return N-(downs+1)

dfs(0)

a = 0
for n in range(N):
    if len(Weight[n]) == 1:
        continue
    c = N2[N-1] - 1
    for w in Weight[n]:
        c = (c - N2[w] + 1) % mod
    a = (a + c) % mod

ans = (a * mod_inv(N2[N])) % mod
print(ans)

import sys
sys.setrecursionlimit(10**6)

N = int(input())
adj = [ [] for _ in range(N+1) ]
for _ in range(N-1):
  a,b = map(int,input().split())
  adj[a].append(b)
  adj[b].append(a)

def dfs(v, p=-1):
  nonlocal ans

  res = 1
  ts = []
  for u in adj[v]:
    if (u==p): continue
    t = dfs(u,v)
    res += t
    ts.append(t)

  if p != -1:
    ts.append(N-res)

  # print(v, ts)

  # now = pow(2, N-1, MOD)-1
  now = pows[N-1]-1
  for t in ts:
    # now -= pow(2, t, MOD)-1
    now -= pows[t] - 1
  ans += now
  return res

ans = 0
MOD = 10**9+7
# 高速化1
pows = [1] * (N+1)
for i in range(1, N+1):
  pows[i] = (pows[i - 1] * 2) % MOD

dfs(1)
print((ans * pow(pows[N], MOD-2, MOD)) % MOD)

import sys
readline = sys.stdin.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  # 行きがけ順探索リスト
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x  # 親ノードを記録
        stack.append(y)

MOD = 10**9 + 7
half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):
    p = parent[v]
    x = size[v]  # vの子孫ノード数（自分も含む）をとる
    size[p] += x  # 親にノード数を加算
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]

ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) % MOD for i in size[2:])  # 解法1の確率式(ノード1を除く)
ans += (1 - power_inv[N]) - N * power_inv[1]  # +  - N/2 
ans %= MOD

print(ans)

import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N = int(input()); MOD=pow(10,9)+7
G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int,input().split()))
  a-=1;b-=1
  G[a].append(b);G[b].append(a)
#print(G)
ans = 0

def dfs(v,p): #自分と親
  nonlocal ans #ansをGlobal変数として宣言
  res = 1 #戻り値。vを含めた部分木のサイズ。自分の分で最初は1
  ts = [] #vから生えている部分木のリスト
  for u in G[v]:
    if u == p:
      continue
    t = dfs(u,v) #uの部分木のサイズが戻り値
    res += t
    ts.append(t)
  if p != -1: #根以外なら親側の部分木が存在する。
    ts.append(N-res)
  now = pow(2,N-1,MOD) - 1 #自分以外を決めるのが2^(N-1)通り。自分以外が全部0が1通り。
  for x in ts:
    now -= pow(2,x,MOD) - 1 #各部分木に一個以上黒がある場合の数。全通り - 全部白
  ans = (ans+now)%MOD
  return res #vを含めた部分木のサイズ

dfs(0,-1)
ALL = pow(2,N,MOD)
#print(ans,ALL)
ans = ans*pow(ALL,MOD-2,MOD)%MOD #フェルマーの小定理より1/ALL = ALL^(MOD-2)
print(ans)


import sys
sys.setrecursionlimit(10**7)
P=10**9+7
N=int(input())
edges = [[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  edges[a-1].append((b-1, i))
  edges[b-1].append((a-1, i))
L=[0]*N
def dfs(cur, x):
  res = 1
  for i in edges[cur]:
    if i[1]!=x:
      res += dfs(i[0], i[1])
  L[x]=res
  return res
dfs(0,-1)
L2=[1]
i2=pow(2,P-2,P)
for i in range(N):
  L2.append(L2[-1]*i2%P)
cnt = 0
for i in L:
  cnt+=(1-L2[i])* (1-L2[N-i])
print((-N*i2-L2[-1]+cnt+1)%P)

from sys import setrecursionlimit
setrecursionlimit(2 * 10 ** 5 + 10)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1]
inv = pow(2, mod - 2, mod)
for i in range(N):
    I.append(I[-1] * inv % mod)

ans = - inv * N - I[N] + 1 + sum((1 - I[x]) * (1 - I[N - x]) for x in X)

print(ans % mod)

import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
AB = [LI() for _ in range(N-1)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]: continue
        parent[y] = x
        stack.append(y)

x = (DVSR + 1) // 2
PWR=[1]*(N+1)
RWP=[1]*(N+1)

for i in range(1,N+1):
    PWR[i] = PWR[i-1] * 2 % DVSR
    RWP[i] = RWP[i-1] * x % DVSR

answer = 0
size = [1] * (N+1)
for v in order[::-1]:
    p = parent[v]
    size[p] += size[v]
    A = [size[w] for w in graph[v] if w != p]
    if v != root: A.append(N - 1 - sum(A))
    if len(A) == 1: continue
    prod = 1
    coef = 1
    for x in A:
        prod *= RWP[x]
        prod %= DVSR
        coef += (PWR[x] - 1)
    E = 1 - prod * coef % DVSR
    answer += E

answer *= RWP[1]
answer %= DVSR
print(answer)

# classを使うのをやめてlistで実施する
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)
import sys
input = sys.stdin.readline

def dfs(v):
    visited[v] = True
    for i in range(len(AL[v][CHILDREN])):
        u = AL[v][CHILDREN][i]
        if visited[u]:
            AL[v][CHILDREN][i] = None
            continue
        AL[v][SIZE] += dfs(u)
    return AL[v][SIZE]


def anaaki(v):
    ret = powp - 1
    for ch in AL[v][CHILDREN]:
        if ch is None: continue
        ret -= pow(2, AL[ch][SIZE], p) - 1
        ret %= p
    ret -= pow(2, n - AL[v][SIZE], p) - 1
    ret %= p
    return ret

n = int(input())
SIZE = 0
CHILDREN = 1
AL = [[1, []] for _ in range(n)]
visited = [False] * n
p = 10 ** 9 + 7
powp = pow(2, n - 1, p)

for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    AL[a][CHILDREN].append(b)
    AL[b][CHILDREN].append(a)

dfs(0)
numer = 0
for i in range(n):
    numer += anaaki(i)
    numer %= p

denom = pow(2, n, p)
print(numer * pow(denom, p - 2, p) % p)

import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1]
inv = pow(2, mod - 2, mod)
for i in range(N):
    I.append(I[-1] * inv % mod)

ans = - inv * N - I[N] + 1 + sum((1 - I[x]) * (1 - I[N - x]) for x in X)
ans %= mod

print(ans)

import sys
sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7

def MOD_inv(a):
    b = MOD
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u = u % MOD
    if u < 0:
        u += MOD
    return u

def cntNode(G, C, crr, pre):
    s = 0
    for i, nxt in enumerate(G[crr]):
        if nxt == pre:
            continue
        else:
            C[crr][i] = cntNode(G, C, nxt, crr)
            s += C[crr][i]
    return s+1

def main():
    n = int(input())
    G = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        G[a].append(b)
        G[b].append(a)
    C = [[-1]*len(G[i]) for i in range(n)]
    idx = -1
    for i in range(n):
        if len(G[i]) == 1:
            idx = i
            break
    cntNode(G, C, idx, -1)
    for i in range(n):
        idx = -1
        s = 0
        for j, v in enumerate(C[i]):
            if v == -1:
                idx = j
            else:
                s += v
        if idx != -1:
            C[i][idx] = n-1 - s
    s = 0
    pows = [0]*(n+1)
    pows[0] = 1
    for i in range(1, n+1):
        pows[i] = 2 * pows[i-1] % MOD
    for i in range(n):
        p = pows[n-1]
        for v in C[i]:
            p -= pows[v] - 1
        p -= 1
        p %= MOD
        s += p
        s %= MOD
    print(s * MOD_inv(pows[n]) % MOD)

def __starting_point():
    main()
__starting_point()

import sys
input = sys.stdin.readline

mod = 10**9+7

def dfs(graph, N):
    ans = 0
    Par = [-1]*N
    Childs = [[] for _ in range(N)]
    stack = [0]
    while stack:
        p = stack.pop()
        if p >= 0:
            stack.append(~p)
            for np in graph[p]:
                if np != 0 and Par[np] == -1:
                    stack.append(np)
                    Par[np] = p
        else:
            p = ~p
            score = pow(2, N-1, mod) - 1
            upper = N-1
            for a in Childs[p]:
                upper -= a
                score = (score - pow(2, a, mod) + 1) % mod
            if p != 0:
                score = (score - pow(2, upper, mod) + 1) % mod
            ans = (ans + score) % mod
            Childs[Par[p]].append(N-1-upper+1)
    
    return ans * pow(2, N*(mod-2), mod) % mod

def main():
    N = int(input())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = list(map(int, input().split()))
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    print((dfs(graph, N)))


def __starting_point():
    main()

__starting_point()

# Surrounded Nodes
import sys
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
N = int(input())
G = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
S = -1
for i in range(1, N+1):
    if len(G[i]) == 1:
        S = i
        break
visited = [False for i in range(N+1)]
parent = [-1 for i in range(N+1)]
count = [1 for i in range(N+1)]

ans = N*pow(2, N-1, mod)


def dfs(node):
    visited[node] = True
    for child in G[node]:
        if visited[child] == False:
            parent[child] = node
            dfs(child)
    for child in G[node]:
        if child != parent[node]:
            count[node] += count[child]


powers = [1 for i in range(2*10**5+1)]
for i in range(1, 2*10**5+1):
    powers[i] = powers[i-1]*2 % mod

dfs(S)

ans = 0
for i in range(1, N+1):
    if len(G[i]) > 1:
        ans += powers[N-1]
        for x in G[i]:
            if x != parent[i]:
                ans -= powers[count[x]]
        ans -= powers[N-count[i]]
        ans += len(G[i]) - 1
        ans %= mod
D = pow(2, N, mod)
print(ans*pow(D, mod-2, mod) % mod)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    MOD = 10**9 + 7

    N = int(input())
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = list(map(int, input().split()))
        a, b = a-1, b-1
        adjL[a].append(b)
        adjL[b].append(a)

    sizeSubtrees = [0] * N
    sizeAdjss = [[] for _ in range(N)]

    def dfs(vNow, vPar):
        sizeSubtrees[vNow] = 1
        for v2 in adjL[vNow]:
            if v2 == vPar: continue
            s = dfs(v2, vNow)
            sizeAdjss[vNow].append(s)
            sizeSubtrees[vNow] += s
        sizeAdjss[vNow].append(N-sizeSubtrees[vNow])
        return sizeSubtrees[vNow]

    dfs(0, -1)

    def getPows(base, n, MOD):
        pows = [1] * (n+1)
        for x in range(1, n+1):
            pows[x] = (pows[x-1] * base) % MOD
        return pows
    pow2s = getPows(2, N, MOD)

    nums = [0] * N
    for v in range(N):
        num = pow2s[N-1] - 1
        for sizeAdj in sizeAdjss[v]:
            num -= pow2s[sizeAdj] - 1
            num %= MOD
        nums[v] = num

    ans = sum(nums) % MOD * pow(pow2s[N], MOD-2, MOD) % MOD
    print(ans)


solve()


N=int(input())
E=[[] for _ in range(N)]
for _ in range(N-1):
    A,B=list(map(int,input().split()))
    E[A-1].append(B-1)
    E[B-1].append(A-1)
MOD=10**9+7

#dp=子ノードの数+1(自分)
dp=[1]*N

root=0
parent=[0]*N
order=[]
def dfs():
    parent[root]=root
    stack=[root]
    while stack:
        node=stack.pop()
        order.append(node)
        for ss in E[node]:
            if parent[node]!=ss:
                stack.append(ss)
                parent[ss]=node

pow2=[1]*(N+1)
for i in range(1,len(pow2)):
    pow2[i]=pow2[i-1]*2%MOD

def solve():
    ans=0
    inv2=pow(2,MOD-2,MOD)
    #p0=すべての部分木に黒頂点が1つも含まれない確率
    p0=pow(pow2[N-1],MOD-2,MOD)
    for i in reversed(order):
        if root!=i:
            dp[parent[i]]+=dp[i]
        p=0
        if len(E[i])>=2:
            #p0*(p1-1)=どれか1つの各部分木に黒頂点が1つ以上含まれる確率
            p1=1
            for s in E[i]:
                size=0
                if parent[i]!=s:
                    size=dp[s]
                elif i!=root:
                    size=N-dp[i]
                else:
                    continue
                p1+=pow2[size]-1
            p=1-(p0*p1)
            p%=MOD
        ans+=p
        ans%=MOD
    #頂点iが白の確率
    ans=ans*inv2%MOD
    print(ans)

dfs()
solve()


def main():
    from sys import stdin
    input = stdin.readline
    mod = 10**9+7
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    pow2 = [1]
    for i in range(200000):
        pow2.append(pow2[-1]*2 % mod)

    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]
    root = 0
    d = [-1]*n
    d[root] = 0
    q = [root]
    cnt = 0
    while q:
        cnt += 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if d[j] == -1:
                    d[j] = cnt
                    qq.append(j)
        q = qq

    for i in range(n):
        di = d[i]
        g[i] = [j for j in g[i] if di <= d[j]]

    d = [j for i, j in sorted([(j, i) for i, j in enumerate(d)])]
    dp = [(0, 0, 1) for _ in [0]*n]

    for i in d[::-1]:
        if g:
            n = sum([dp[j][2] for j in g[i]])+1
            x, y = pow(2, n-1, mod)-1, 0
            for j in g[i]:
                xj, yj, nj = dp[j]
                p1, p2 = pow2[n-nj], pow2[nj]
                x += xj*p1+yj*(p1-1)-p2+1
                y += yj+p2-1
            dp[i] = (x % mod, y % mod, n)

    x = dp[0][0]
    y = pow(2, dp[0][2], mod)
    print((x*pow(y, mod-2, mod) % mod))


main()


# ref https://qiita.com/ZhangChaoran/items/71fab0e4b8647a93d3a0
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
g = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a].append(b)
    g[b].append(a)

mod = 10**9 + 7
par = [0] * (n + 1)
order = []
stk = deque()
stk.append(1)

while stk:
    v = stk.pop()
    order.append(v)
    for x in g[v]:
        if x == par[v]:
            continue
        par[x] = v
        stk.append(x)

rev = (mod + 1) // 2
po2_inv = [1] * (n + 1)
size = [1] * (n + 1)
for i, y in enumerate(order[::-1], 1):
    p = par[y]
    size[p] += size[y]
    po2_inv[i] = po2_inv[i - 1] * rev % mod

ans = 1
for i in size[2:]:
    ans += (1 - po2_inv[i] - po2_inv[n - i] + po2_inv[n]) % mod
ans -= po2_inv[n] + n * po2_inv[1]
ans %= mod
print(ans)


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
MOD = 10**9 + 7
tree = [[] for i in range(N+1)]
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree[b].append(a)

# 頂点1をルートにして各頂点より下にある部分木の頂点数を求めていく
root, par = 1, 0
sizes = [0] * (N+1)
order = [[root, par]]
def calc_nums(node, par):
  nonlocal sizes
  nonlocal order
  if sizes[node] > 0:
    return sizes[node]
  children = tree[node]
  res = 1
  for child in children:
    if child == par:
      continue
    order.append([child, node])
    res += calc_nums(child, node)
  sizes[node] = res
  return res

_ = calc_nums(root, par)

# 2の累乗を事前に計算しておく
prod2 = [1]
for i in range(N):
  prod2.append(prod2[-1] * 2 % MOD)

# 各頂点について、その頂点が穴あき度としてカウントされる状況を独立に計算する
demo = 0 # 分子
div = prod2[N] # 分母
base = prod2[N-1] - 1
for node, par in order:
  children = tree[node]
  num = base
  num_par = N - 1
  for child in children:
    if child == par:
      continue
    s = sizes[child]
    num_par -= s
    num -= prod2[s] - 1 
  num -= prod2[num_par] - 1
  demo += num
    
ans = demo * pow(div, MOD-2, MOD) % MOD
print(ans)

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def dfs(u=0, pu=-1):
        res = 1
        for cu in to[u]:
            if cu == pu: continue
            ret = dfs(cu, u)
            children_size[u].append(ret)
            res += ret
        return res

    md = 10 ** 9 + 7
    n = II()
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        to[a].append(b)
        to[b].append(a)
    #print(to)

    # 1/2をmodで表して、累乗を事前計算
    half = pow(2, md - 2, md)
    exp_half = [1, half]
    for _ in range(n):
        exp_half.append(exp_half[-1] * half % md)
    # print(exp_half)

    # 子の部分木のサイズ(要素数)をdfsで求める
    children_size = [[] for _ in range(n)]
    dfs()
    # print(children_size)

    # それぞれの頂点において、接続する部分木のうち
    # 2つ以上の部分木に黒が含まれる確率を求める
    # 余事象を利用(1-黒を含む部分木がない確率-黒を含む部分木が1つの確率)
    # (その頂点が白の確率)×(上記の確率)がその頂点が白で残る期待値なので和を求めれば答え
    ans = 0
    noblack = exp_half[n - 1]
    for cs in children_size:
        if not cs: continue
        sum_cs = sum(cs)
        if sum_cs != n - 1: cs.append(n - 1 - sum_cs)
        onlyone = 0
        for child_size in cs:
            onlyone += (1 - exp_half[child_size]) * exp_half[n - 1 - child_size]
        ans += (1 - noblack - onlyone) * half
        ans %= md
    print(ans)

main()


import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = - inv * N - I[N] + 1
for e in range(N - 1):
    ans += (1 - I[X[e]]) * (1 - I[N - X[e]])
    ans %= mod

print(ans)

# 75

import sys
sys.setrecursionlimit(10**8)

MOD = 10**9+7
N = int(input())
g_l = [[] for i in range(N)]
check_l = [-1] * N
num_l = [0] * N
for i in range(N-1):
    ai, bi = list(map(int, input().split()))
    g_l[ai-1].append(bi-1)
    g_l[bi-1].append(ai-1)


def dfs(n):
    d = 1
    if check_l[n] > 0:
        return num_l[n]
    check_l[n] = 1
    for next_n in g_l[n]:
        d += dfs(next_n)
    num_l[n] = d
    return d


def modinv(a):
    # calc : (a**(-1)) %MOD
    return pow(a, MOD-2, MOD)


def solve():
    dfs(0)
    pow_l = [None]*(N+1)
    pow_l[0] = 1
    for i in range(1, N+1):
        pow_l[i] = (pow_l[i-1] * 2) % MOD

    ans = 0
    # for i in range(1, N):
    #     ans += (1 - (1/2)**num_l[i]) * (1 - (1/2)**(N-num_l[i]))
    # ans += 1 - (1/2)**N  # 辺の期待値→頂点の期待値に変換(空集合以外は+1される)
    # ans -= N/2  # 黒点の期待値を引く
    for i in range(1, N):
        ans = (ans + (pow_l[num_l[i]]-1) *
               (pow_l[N-num_l[i]]-1) % MOD) % MOD
    ans = (ans + (pow_l[N] - 1) - (N * pow_l[N-1]) % MOD) % MOD
    y = ans
    x = pow(2, N, MOD)

    z = (y * modinv(x)) % MOD

    print(z)


solve()


#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def calc_fraction_mod(numerator, denominator):
    '''
        returns numerator / denominator (mod MOD)
    '''
    inv = pow(denominator, MOD - 2, MOD)
    return numerator * inv % MOD

def solve(N: int, A: "List[int]", B: "List[int]"):
    conns = [[] for _ in range(N)]
    for i in range(N - 1):
        conns[A[i] - 1].append(B[i] - 1)
        conns[B[i] - 1].append(A[i] - 1)

    pows = []
    for i in range(N + 1):
        pows.append(pow(2, i, MOD))

    num = [0]
    visited = [False] * N
    def dfs(idx):
        visited[idx] = True
        children = 0
        subs = []
        for c in conns[idx]:
            if visited[c]:
                continue
            sub = dfs(c)
            children += sub
            subs.append(sub)
        subs.append(N - children - 1)
        #tmp = pow(2, N - 1, MOD)
        tmp = pows[N - 1]
        tmp -= 1 # all white
        for sub in subs:
            #tmp -= pow(2, sub, MOD) - 1
            tmp -= pows[sub] - 1
        num[0] += tmp
        return children + 1
    dfs(0)

    #deno = pow(2, N, MOD)
    deno = pows[N]
    num = num[0]
    ret = calc_fraction_mod(num, deno)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N - 1)  # type: "List[int]"
    B = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(2*10**5)
input = sys.stdin.readline


def calc_counts(n, edges):
    counts = [0] * n
    seen = [False] * n
    dfs(0, edges, seen, counts)
    return counts


def dfs(node, edges, seen, counts):
    count = 1
    seen[node] = True
    for to in edges[node]:
        if seen[to]:
            continue
        count += dfs(to, edges, seen, counts)
    counts[node] = count
    return count


def calc_blank(node, counts: list, edges, all, mod=10**9+7):
    n = len(counts)
    paths = edges[node]
    if len(paths) <= 1:
        return 0
    base = counts[node]
    result = all - 1
    for v in paths:
        count = counts[v]
        if count > base:
            count = n - base
        result -= pow(2, count, mod) - 1
        result %= mod

    return result


def main():
    mod = 10**9 + 7
    n = int(input())
    edges = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = list(map(int, input().split()))
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    counts = calc_counts(n, edges)
    all = pow(2, n-1, mod)
    blanks = 0
    for node in range(n):
        blank = calc_blank(node, counts, edges, all)
        blanks += blank
        blanks %= mod

    inv_denominator = pow(pow(2, n, mod), mod-2, mod)
    ans = blanks * inv_denominator % mod
    print(ans)


def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline

N = int(readline())

adj = [[] for i in range(N)]
for i in range(N - 1):
    A, B = list(map(int, readline().split()))
    A -= 1
    B -= 1
    adj[A].append(B)
    adj[B].append(A)

mod = 10 ** 9 + 7
pow2 = [1] * (N + 1)
for i, j in zip(list(range(N)), list(range(1, N + 1))):
    pow2[j] = pow2[i] * 2 % mod

ans = 0


def dfs(node, parent):
    nonlocal ans
    cnt = 1
    
    for child in adj[node]:
        if child != parent:
            cnt += dfs(child, node)
    
    ans += (pow2[cnt] - 1) * (pow2[N-cnt] - 1)
    ans %= mod
    
    return cnt

dfs(0, None)

ans = (ans - N * pow2[N-1] + pow2[N] - 1) % mod
ans = ans * pow(pow2[N], mod - 2, mod) % mod

print(ans)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def main():
  MOD = 10**9+7
  n = int(input())
  T = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)
  C = [[] for _ in range(n)]
  seen = [False]*n
  dp = [0]*n
  def dfs(v):
    cnt = 1
    seen[v] = True
    for nv in T[v]:
      if seen[nv]:
        continue
      C[v].append(nv)
      cnt += dfs(nv)
    dp[v] = cnt
    return cnt

  dfs(0)

  p = [1]*(n+1)
  inv = [1]*(n+1)
  inv_two = pow(2, MOD-2, MOD)
  for i in range(n):
    p[i+1] = p[i] * 2 % MOD
    inv[i+1] = inv[i] * inv_two % MOD
  ans = 0
  for i in range(n):
    s = 1
    t = 1
    cnt = 1
    for c in C[i]:
      l = dp[c]
      s *= inv[l]
      s %= MOD
      t += p[l] - 1
      t %= MOD
      cnt += l
    r = n - cnt
    s *= inv[r]
    s %= MOD
    t += p[r] - 1
    t %= MOD
    res = (1 - s*t) % MOD * inv_two
    res %= MOD
    ans += res
    ans %= MOD
  print(ans)

def __starting_point():
  main()
__starting_point()

import sys
sys.setrecursionlimit(1000000)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = - inv * N - I[N] + 1
for e in range(N - 1):
    ans += (1 - I[X[e]]) * (1 - I[N - X[e]])
    ans %= mod

print(ans)

import sys
sys.setrecursionlimit(10**9)

reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

mod = 10**9+7

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = list(map(int, input().split()))
    a,b = a-1,b-1
    G[a].append(b)
    G[b].append(a)

cnt = [0]*n
def dfs(cur, prev):
    tmp = 1
    for to in G[cur]:
        if to != prev:
            tmp += dfs(to, cur)
    cnt[cur] = tmp
    return tmp

dfs(0, -1)

power = [0]*(n)
powe2_n = pow(2, n, mod)
powe2_n = pow(powe2_n, mod-2, mod)
power[n-1] = powe2_n
for i in reversed(list(range(n-1))):
    powe2_n *= 2
    powe2_n %= mod
    power[i] = powe2_n
ans = 0
from collections import deque
que = deque()
que.append((0, -1))

while que:
    cur, prev = que.pop()
    if len(G[cur]) == 1:
        if prev == -1:
            que.append((G[cur][0], cur))
        continue

    prob = 1
    prob -= power[n-2]

    for to in G[cur]:
        if to == prev:
            bubun_cnt = n-cnt[cur]
        else:
            que.append((to, cur))
            bubun_cnt = cnt[to]
        tmp = 1-power[bubun_cnt-1]
        tmp *= power[n-1-bubun_cnt-1]
        prob -= tmp
    prob %= mod
    ans += power[0]*prob
    ans %= mod

print(ans)



import sys
readline = sys.stdin.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  # 行きがけ順探索リスト
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x  # 親ノードを記録
        stack.append(y)

MOD = 10**9 + 7
half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):
    p = parent[v]
    x = size[v]  # vの子孫ノード数（自分も含む）をとる
    size[p] += x  # 親にノード数を加算
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]

ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) % MOD for i in size[2:])  # 解法1の確率式：辺iがSに含まれるための必要十分条件
ans += (1 - power_inv[N]) - N * power_inv[1]  # + 「(空グラフでない」 - N/2 
ans %= MOD

print(ans)

import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: list(map(int, readline().split()))
nl = lambda: list(map(int, readline().split()))


n = ni()
G = [list() for _ in range(n)]
for _ in range(n-1):
  a, b = nm()
  a -= 1; b -= 1
  G[a].append(b)
  G[b].append(a)
  
  
mod = 10**9 + 7
dub = [1]*(n+1)
for i in range(n):
  dub[i+1] = dub[i] * 2
  if dub[i+1] > mod:
    dub[i+1] -= mod
    
size = [1]*n
def dfs_depandsize(tree,v,p):
    for x in tree[v]:
        if x == p:
            continue
        size[v] += dfs_depandsize(tree,x,v)
    return size[v]
dfs_depandsize(G, 0, -1)
ans = 0
for v in range(n):
  c = 0
  res = 1
  for x in G[v]:
    if size[x] < size[v]:
      c += size[x]
      res += dub[size[x]] - 1
  res += dub[n-1-c] - 1
  res %= mod
  ans = (ans + dub[n-1] - res) % mod
print((ans * pow(dub[n], mod-2, mod) % mod))


import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    MOD = 1000000007
    N, *AB = list(map(int, read().split()))
    G = [[] for _ in range(N)]
    for a, b in zip(AB[::2], AB[1::2]):
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    stack = deque([0])
    order = []
    prev = [0] * N
    prev[0] = -1
    while stack:
        v = stack.pop()
        order.append(v)
        for nv in G[v]:
            if nv != prev[v]:
                stack.append(nv)
                prev[nv] = v

    pow2 = [0] * (N + 1)
    pow2[0] = 1
    for i in range(N):
        pow2[i + 1] = pow2[i] * 2 % MOD

    nodes = [1] * N
    numer = 0

    for v in reversed(order):
        if prev[v] != -1:
            nodes[prev[v]] += nodes[v]
        numer = (numer + pow2[N - 1] - 1 - (pow2[N - nodes[v]] - 1)) % MOD
        for nv in G[v]:
            if nv != prev[v]:
                numer = (numer - (pow2[nodes[nv]] - 1)) % MOD

    denom = pow2[N]
    ans = (numer * pow(denom, MOD - 2, MOD)) % MOD
    print(ans)
    return


def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = - inv * N - I[N] + 1 + sum((1 - I[x]) * (1 - I[N - x]) for x in X)
ans %= mod

print(ans)

import sys
readline = sys.stdin.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

MOD = 10**9 + 7
half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):
    p = parent[v]
    x = size[v]
    size[p] += x
    power_inv[i] = power_inv[i - 1] * half % MOD

ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) % MOD for i in size[2:])
ans -= N * power_inv[1] + power_inv[N] - 1
ans %= MOD

print(ans)