import sys

sys.setrecursionlimit(10**8)



N = int(eval(input()))

edge = [[] for _ 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)



def dfs(v,mod):

  black,white = 1,1

  for u in edge[v]:

    if visited[u]==False:

      visited[u]=True

      b,w = dfs(u,mod)

      black *= w

      white *= b+w

  black %= mod

  white %= mod

  return black,white



mod = 10**9+7

visited = [False]*N

visited[0]=True

black,white = dfs(0,mod)

print(((black+white)%mod))
import sys

input = sys.stdin.readline



N = int(eval(input()))

edge = [[] for _ 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)



def dfs(start):

  stack = [start]

  parent = [N]*N

  parent[start] = -1

  white, black = [1]*N, [1]*N

  while stack:

    v = stack[-1]

    marker = 0

    for u in edge[v]:

      if u==parent[v]:

        continue

      if parent[u]==N: #子へ降ろす

        marker = 1

        parent[u]=v

        stack.append(u)

      else: #子から吸い上げる

        white[v] *= white[u]+black[u]

        white[v] %= mod

        black[v] *= white[u]

        black[v] %= mod

    if marker==0:

      stack.pop()

  ans = (black[0]+white[0])%mod

  return ans



mod = 10**9+7

ans = dfs(0)

print(ans)

import sys

sys.setrecursionlimit(10**8)
N = int(eval(input()))
edge = [[] for _ 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)


def dfs(v, mod):
    black, white = 1, 1
    for u in edge[v]:
        if visited[u] == False:
            visited[u] = True
            b, w = dfs(u, mod)
            black *= w
            white *= b + w
    black %= mod
    white %= mod
    return black, white


mod = 10**9 + 7
visited = [False] * N
visited[0] = True
black, white = dfs(0, mod)
print(((black + white) % mod))

import sys

input = sys.stdin.readline
N = int(eval(input()))
edge = [[] for _ 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)


def dfs(start):
    stack = [start]
    parent = [N] * N
    parent[start] = -1
    white, black = [1] * N, [1] * N
    while stack:
        v = stack[-1]
        marker = 0
        for u in edge[v]:
            if u == parent[v]:
                continue
            if parent[u] == N:  # 子へ降ろす
                marker = 1
                parent[u] = v
                stack.append(u)
            else:  # 子から吸い上げる
                white[v] *= white[u] + black[u]
                white[v] %= mod
                black[v] *= white[u]
                black[v] %= mod
        if marker == 0:
            stack.pop()
    ans = (black[0] + white[0]) % mod
    return ans


mod = 10**9 + 7
ans = dfs(0)
print(ans)

-sys.setrecursionlimit(10**8) +input = sys.stdin.readline -def dfs(v, mod): -    black, white = 1, 1 -    for u in edge[v]: -        if visited[u] == False: -            visited[u] = True -            b, w = dfs(u, mod) -            black *= w -            white *= b + w -    black %= mod -    white %= mod -    return black, white +def dfs(start): +    stack = [start] +    parent = [N] * N +    parent[start] = -1 +    white, black = [1] * N, [1] * N +    while stack: +        v = stack[-1] +        marker = 0 +        for u in edge[v]: +            if u == parent[v]: +                continue +            if parent[u] == N:  # 子へ降ろす +                marker = 1 +                parent[u] = v +                stack.append(u) +            else:  # 子から吸い上げる +                white[v] *= white[u] + black[u] +                white[v] %= mod +                black[v] *= white[u] +                black[v] %= mod +        if marker == 0: +            stack.pop() +    ans = (black[0] + white[0]) % mod +    return ans -visited = [False] * N -visited[0] = True -black, white = dfs(0, mod) -print(((black + white) % mod)) +ans = dfs(0) +print(ans)