import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



MOD = 10 ** 9 + 7

N = int(eval(input()))

graph = [[] for _ in range(N+1)]

for _ in range(N-1):

    x,y = list(map(int,input().split()))

    graph[x].append(y)

    graph[y].append(x)



def dfs(x=1,parent=None):

    b,w = 1,1 # 子がすべて白、子が何でもよい

    for y in graph[x]:

        if y == parent:

            continue

        b1,w1 = dfs(y,x)

        b *= w1

        w *= (b1+w1)

        b %= MOD

        w %= MOD

    return b,w



b,w = dfs()

answer = (b+w) % MOD

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N = int(readline())

m = list(map(int,read().split()))

XY = list(zip(m,m))



MOD = 10**9 + 7



graph = [[] for _ in range(N+1)]

for x,y in XY:

    graph[x].append(y)

    graph[y].append(x)



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)



dp_w = [1] * (N+1) # 根が白

dp_b = [1] * (N+1)



for x in order[::-1]:

    w = dp_w[x]; b = dp_b[x]

    p = parent[x]

    dp_w[p] *= (b+w); dp_w[p] %= MOD

    dp_b[p] *= w; dp_b[p] %= MOD



answer = (dp_w[1] + dp_b[1]) % MOD

print(answer)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
N = int(eval(input()))
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = list(map(int, input().split()))
    graph[x].append(y)
    graph[y].append(x)


def dfs(x=1, parent=None):
    b, w = 1, 1  # 子がすべて白、子が何でもよい
    for y in graph[x]:
        if y == parent:
            continue
        b1, w1 = dfs(y, x)
        b *= w1
        w *= b1 + w1
        b %= MOD
        w %= MOD
    return b, w


b, w = dfs()
answer = (b + w) % MOD
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
m = list(map(int, read().split()))
XY = list(zip(m, m))
MOD = 10**9 + 7
graph = [[] for _ in range(N + 1)]
for x, y in XY:
    graph[x].append(y)
    graph[y].append(x)
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)
dp_w = [1] * (N + 1)  # 根が白
dp_b = [1] * (N + 1)
for x in order[::-1]:
    w = dp_w[x]
    b = dp_b[x]
    p = parent[x]
    dp_w[p] *= b + w
    dp_w[p] %= MOD
    dp_b[p] *= w
    dp_b[p] %= MOD
answer = (dp_w[1] + dp_b[1]) % MOD
print(answer)

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N = int(readline()) +m = list(map(int, read().split())) +XY = list(zip(m, m)) -N = int(eval(input())) -for _ in range(N - 1): -    x, y = list(map(int, input().split())) +for x, y in XY: - - -def dfs(x=1, parent=None): -    b, w = 1, 1  # 子がすべて白、子が何でもよい +root = 1 +parent = [0] * (N + 1) +order = [] +stack = [root] +while stack: +    x = stack.pop() +    order.append(x) -        if y == parent: +        if y == parent[x]: -        b1, w1 = dfs(y, x) -        b *= w1 -        w *= b1 + w1 -        b %= MOD -        w %= MOD -    return b, w - - -b, w = dfs() -answer = (b + w) % MOD +        parent[y] = x +        stack.append(y) +dp_w = [1] * (N + 1)  # 根が白 +dp_b = [1] * (N + 1) +for x in order[::-1]: +    w = dp_w[x] +    b = dp_b[x] +    p = parent[x] +    dp_w[p] *= b + w +    dp_w[p] %= MOD +    dp_b[p] *= w +    dp_b[p] %= MOD +answer = (dp_w[1] + dp_b[1]) % MOD