#n == 1でバグるけど2が返ってくるのでヨシ！

from sys import setrecursionlimit

setrecursionlimit(10 ** 9)



n = int(eval(input()))

X = [[int(i) for i in input().split()] for j in range(n-1)]

p = 10 ** 9 + 7



V = [[] for i in range(n+1)]

for x, y in X:

    V[x].append(y)

    V[y].append(x)



root = 0

for i, v in enumerate(V):

    if len(v) == 1:

        root = i

        break



w = 0

b = 1

DP = [[0] *  2 for i in range(n+1)]



def dfs(i):

    if DP[i] != [0, 0]:

        return 0

    DP[i][w] = 1

    DP[i][b] = 1

    for v in V[i]:

        if dfs(v) == 0:

            continue

        DP[i][w] *= DP[v][w] + DP[v][b]

        DP[i][b] *= DP[v][w]

        DP[i][w] %= p

        DP[i][b] %= p



dfs(root)

print((sum(DP[root]) % p))        
#n == 1でバグるけど2が返ってくるのでヨシ！

from sys import setrecursionlimit

setrecursionlimit(10 ** 9)



n = int(eval(input()))

X = [[int(i) for i in input().split()] for j in range(n-1)]

p = 10 ** 9 + 7



V = [[] for i in range(n+1)]

for x, y in X:

    V[x].append(y)

    V[y].append(x)



w = 0

b = 1

DP = [[0] *  2 for i in range(n+1)]



def dfs(i):

    if DP[i] != [0, 0]:

        return 0

    DP[i][w] = 1

    DP[i][b] = 1

    for v in V[i]:

        if dfs(v) == 0:

            continue

        DP[i][w] *= DP[v][w] + DP[v][b]

        DP[i][b] *= DP[v][w]

        DP[i][w] %= p

        DP[i][b] %= p



dfs(1)

print((sum(DP[1]) % p))        
# n == 1でバグるけど2が返ってくるのでヨシ！
from sys import setrecursionlimit

setrecursionlimit(10**9)
n = int(eval(input()))
X = [[int(i) for i in input().split()] for j in range(n - 1)]
p = 10**9 + 7
V = [[] for i in range(n + 1)]
for x, y in X:
    V[x].append(y)
    V[y].append(x)
root = 0
for i, v in enumerate(V):
    if len(v) == 1:
        root = i
        break
w = 0
b = 1
DP = [[0] * 2 for i in range(n + 1)]


def dfs(i):
    if DP[i] != [0, 0]:
        return 0
    DP[i][w] = 1
    DP[i][b] = 1
    for v in V[i]:
        if dfs(v) == 0:
            continue
        DP[i][w] *= DP[v][w] + DP[v][b]
        DP[i][b] *= DP[v][w]
        DP[i][w] %= p
        DP[i][b] %= p


dfs(root)
print((sum(DP[root]) % p))

# n == 1でバグるけど2が返ってくるのでヨシ！
from sys import setrecursionlimit

setrecursionlimit(10**9)
n = int(eval(input()))
X = [[int(i) for i in input().split()] for j in range(n - 1)]
p = 10**9 + 7
V = [[] for i in range(n + 1)]
for x, y in X:
    V[x].append(y)
    V[y].append(x)
w = 0
b = 1
DP = [[0] * 2 for i in range(n + 1)]


def dfs(i):
    if DP[i] != [0, 0]:
        return 0
    DP[i][w] = 1
    DP[i][b] = 1
    for v in V[i]:
        if dfs(v) == 0:
            continue
        DP[i][w] *= DP[v][w] + DP[v][b]
        DP[i][b] *= DP[v][w]
        DP[i][w] %= p
        DP[i][b] %= p


dfs(1)
print((sum(DP[1]) % p))

-root = 0 -for i, v in enumerate(V): -    if len(v) == 1: -        root = i -        break -dfs(root) -print((sum(DP[root]) % p)) +dfs(1) +print((sum(DP[1]) % p))