#EDPC P_Independent_Set

import sys

input = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 7)

 

N = int(eval(input()))

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

mod = 10 ** 9 + 7

 

for _ in range(N - 1):

    a, b = list(map(int, input().split()))

    edge[a].append(b)

    edge[b].append(a)



root = 1

 

black = [1] * (N + 1)

white = [1] * (N + 1)

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

seen = [False] * (N + 1)



#節点iの子のリストを作成

node = [root]

while node:

    s = node.pop()

    seen[s] = True

    for t in edge[s]:

        if seen[t]:

            continue

        node.append(t)

        under[s].append(t)



def BW(s):

    if not under[s]: #葉なら白黒1色ずつ

        return

    for t in under[s]:

        BW(t)

        white[s] = (white[s] * (white[t] + black[t])) % mod

        black[s] = (black[s] * white[t]) % mod



BW(root)

ans = white[root]+black[root]

print((ans%mod))

    

 



from collections import deque

N = int(eval(input()))

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

for _ in range(N - 1):

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

    edge[x].append(y)

    edge[y].append(x)



mod = 10 ** 9 + 7



parent = [-1] * (N + 1)

node = deque([1])

ts = []

while node:

    s = node.popleft()

    ts.append(s)

    for t in edge[s]:

        if t == parent[s]:

            continue

        parent[t] = s

        node.append(t)



black = [1] * (N + 1)

white = [1] * (N + 1)



while ts:

    s = ts.pop()

    b = 1

    w = 1

    for t in edge[s]:

        if parent[s] == t:

            continue

        b = b * white[t] % mod

        w = w * (white[t] + black[t]) % mod

    black[s] = b

    white[s] = w



print(((black[1] + white[1]) % mod))
# EDPC P_Independent_Set
import sys

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
edge = [[] for _ in range(N + 1)]
mod = 10**9 + 7
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a].append(b)
    edge[b].append(a)
root = 1
black = [1] * (N + 1)
white = [1] * (N + 1)
under = [[] for _ in range(N + 1)]
seen = [False] * (N + 1)
# 節点iの子のリストを作成
node = [root]
while node:
    s = node.pop()
    seen[s] = True
    for t in edge[s]:
        if seen[t]:
            continue
        node.append(t)
        under[s].append(t)


def BW(s):
    if not under[s]:  # 葉なら白黒1色ずつ
        return
    for t in under[s]:
        BW(t)
        white[s] = (white[s] * (white[t] + black[t])) % mod
        black[s] = (black[s] * white[t]) % mod


BW(root)
ans = white[root] + black[root]
print((ans % mod))

from collections import deque

N = int(eval(input()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = list(map(int, input().split()))
    edge[x].append(y)
    edge[y].append(x)
mod = 10**9 + 7
parent = [-1] * (N + 1)
node = deque([1])
ts = []
while node:
    s = node.popleft()
    ts.append(s)
    for t in edge[s]:
        if t == parent[s]:
            continue
        parent[t] = s
        node.append(t)
black = [1] * (N + 1)
white = [1] * (N + 1)
while ts:
    s = ts.pop()
    b = 1
    w = 1
    for t in edge[s]:
        if parent[s] == t:
            continue
        b = b * white[t] % mod
        w = w * (white[t] + black[t]) % mod
    black[s] = b
    white[s] = w
print(((black[1] + white[1]) % mod))

-# EDPC P_Independent_Set -import sys +from collections import deque -input = sys.stdin.buffer.readline -sys.setrecursionlimit(10**7) +for _ in range(N - 1): +    x, y = list(map(int, input().split())) +    edge[x].append(y) +    edge[y].append(x) -for _ in range(N - 1): -    a, b = list(map(int, input().split())) -    edge[a].append(b) -    edge[b].append(a) -root = 1 +parent = [-1] * (N + 1) +node = deque([1]) +ts = [] +while node: +    s = node.popleft() +    ts.append(s) +    for t in edge[s]: +        if t == parent[s]: +            continue +        parent[t] = s +        node.append(t) -under = [[] for _ in range(N + 1)] -seen = [False] * (N + 1) -# 節点iの子のリストを作成 -node = [root] -while node: -    s = node.pop() -    seen[s] = True +while ts: +    s = ts.pop() +    b = 1 +    w = 1 -        if seen[t]: +        if parent[s] == t: -        node.append(t) -        under[s].append(t) - - -def BW(s): -    if not under[s]:  # 葉なら白黒1色ずつ -        return -    for t in under[s]: -        BW(t) -        white[s] = (white[s] * (white[t] + black[t])) % mod -        black[s] = (black[s] * white[t]) % mod - - -BW(root) -ans = white[root] + black[root] -print((ans % mod)) +        b = b * white[t] % mod +        w = w * (white[t] + black[t]) % mod +    black[s] = b +    white[s] = w +print(((black[1] + white[1]) % mod))