# coding: utf-8

# Your code here!

import sys

sys.setrecursionlimit(10**7)

MOD=10**9+7



n=int(eval(input()))

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

for _ in range(n-1):

    p,q = [int(i)-1 for i in input().split()]

    edge[p].append(q)

    edge[q].append(p)



    

used = [0]*n



def dfs(x):

    used[x] = 1

    cb=1; cw=1;

    for e in edge[x]:

        if used[e]: continue

        eb,ew = dfs(e)

        cb*=ew

        cb%=MOD

        cw*=(eb+ew)

        cw%=MOD        

    return (cb,cw)



print((sum(dfs(0))%MOD))



# coding: utf-8

# Your code here!

import sys

sys.setrecursionlimit(10**6)

readline = sys.stdin.readline

 

n = int(eval(input()))

#n,q = [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)

 

MOD = 10**9+7

def dfs(v,p): #p: parent of v

    b = w = 1

    for c in g[v]:

        if c == p: continue

        bb, ww = dfs(c,v)

        b *= ww

        b %= MOD        

        w *= bb+ww

        w %= MOD

    return b,w



print((sum(dfs(0,-1))%MOD))

 
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
n = int(eval(input()))
edge = [[] for _ in range(n)]
for _ in range(n - 1):
    p, q = [int(i) - 1 for i in input().split()]
    edge[p].append(q)
    edge[q].append(p)
used = [0] * n


def dfs(x):
    used[x] = 1
    cb = 1
    cw = 1
    for e in edge[x]:
        if used[e]:
            continue
        eb, ew = dfs(e)
        cb *= ew
        cb %= MOD
        cw *= eb + ew
        cw %= MOD
    return (cb, cw)


print((sum(dfs(0)) % MOD))

# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(eval(input()))
# n,q = [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)
MOD = 10**9 + 7


def dfs(v, p):  # p: parent of v
    b = w = 1
    for c in g[v]:
        if c == p:
            continue
        bb, ww = dfs(c, v)
        b *= ww
        b %= MOD
        w *= bb + ww
        w %= MOD
    return b, w


print((sum(dfs(0, -1)) % MOD))

-sys.setrecursionlimit(10**7) +sys.setrecursionlimit(10**6) +readline = sys.stdin.readline +n = int(eval(input())) +# n,q = [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) -n = int(eval(input())) -edge = [[] for _ in range(n)] -for _ in range(n - 1): -    p, q = [int(i) - 1 for i in input().split()] -    edge[p].append(q) -    edge[q].append(p) -used = [0] * n -def dfs(x): -    used[x] = 1 -    cb = 1 -    cw = 1 -    for e in edge[x]: -        if used[e]: +def dfs(v, p):  # p: parent of v +    b = w = 1 +    for c in g[v]: +        if c == p: -        eb, ew = dfs(e) -        cb *= ew -        cb %= MOD -        cw *= eb + ew -        cw %= MOD -    return (cb, cw) +        bb, ww = dfs(c, v) +        b *= ww +        b %= MOD +        w *= bb + ww +        w %= MOD +    return b, w -print((sum(dfs(0)) % MOD)) +print((sum(dfs(0, -1)) % MOD))