stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ull unsigned long long

#define ll long long

#define pb push_back

#define endl '\n'

#define line cout<<"----------------------"<<endl

#define mp make_pair

#define mod 1000000007

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)

#define filein freopen("input.txt","r",stdin)

#define fileout freopen("output.txt","w",stdout)

using namespace std;

const ll  mx=200009;

vector<ll > v[mx];

ll  sub[mx];

pair<ll ,ll > call(ll  s, ll  par)

{

    ll  white=1,black=1;

    for(auto x: v[s])

    {

        if(x==par) continue;

        pair<ll ,ll > temp=call(x,s);

        white=white*(temp.first+temp.second);

        white%=mod;

        black=black*temp.first;

        black%=mod;

    }

    return {white,black};

}

int  main()

{



    ll  n;

    cin>>n;

    for(ll  i=0;i<n-1;i++)

    {

        ll  a,b;

        cin>>a>>b;

        v[a].pb(b);

        v[b].pb(a);

    }

    pair<ll ,ll > ans=call(1,-1);

    cout<<(ans.first+ans.second)%mod<<endl;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f

#define INF 0x3f3f3f3f

#define pb push_back

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define ms(a, x) memset(a, x, sizeof(a))

#define for0(i, n) for(int i = 0; i < n; ++i)

#define for1(i, n) for(int i = 1; i <= n; ++i)

using namespace std;

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<long long, int> pli;

typedef pair<long long, long long> pll;

const int mod = 1e9 + 7;

const int N = 1e5+10;

const int M = 1e6+10;

/*=================================================================================*/



int n, tot, head[N], ver[N<<2], nex[N<<2];

ll dp[N][2];



void add(int x, int y) {

   ver[++tot] = y;

   nex[tot] = head[x];

   head[x] = tot;

}



void dfs(int x, int fa) {

   ll a = 1, b = 1;

   if(nex[head[x]] == 0 && ver[head[x]] == fa) {

      dp[x][0] = dp[x][1] = 1;

      return;

   }

   for(int i = head[x]; i; i = nex[i]) {

      int y = ver[i];

      if(y == fa) continue;

      dfs(y, x);

      a = (a * ((dp[y][0] + dp[y][1]) % mod)) % mod;

      b = (b * dp[y][0]) % mod;

   }

   dp[x][0] = a, dp[x][1] = b;

}



int main() {

   cin>>n;

   for0(i, n-1) {

      int x, y;

      scanf("%d %d", &x, &y);

      add(x, y), add(y, x);

   }

   dfs(1, 0);

   cout << (dp[1][0] + dp[1][1]) % mod << endl;

   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//                                      KiSmAt

#include "bits/stdc++.h"

using namespace std;

 

using ll = long long;

 

const ll inf = 1e18;

const int mod = 1e9 + 7;

const int N = 2 * 1e5 + 10;



ll res;

ll a[N];

ll dp[N][3];



vector<ll> v[N];



inline ll add(ll x, ll y){  return  (x % mod + y % mod) % mod;}

inline ll sub(ll x, ll y){  return  (x % mod - y % mod + mod) % mod;}

inline ll mul(ll x, ll y){  x %= mod;   y %= mod;   return 1LL * x * y % mod;}



ll dfs(ll node, ll par, ll prev){

    if(dp[node][prev] + 1)  return dp[node][prev];

    ll xx = 1, yy = 0;

    for(auto i: v[node]){

        if(i != par)    xx = mul(xx, dfs(i, node, 0));

    }

    if(prev < 1){

        yy = 1;

        for(auto i: v[node]){

            if(i != par)    yy = mul(yy, dfs(i, node, prev + 1));

        }

    }

    return dp[node][prev] = add(xx, yy);

}



void solve(){

    ll n, x, y;

    cin >> n;

    for(int i = 0; i < n - 1; ++i){

        cin >> x >> y;

        v[y].push_back(x);

        v[x].push_back(y);

    }

    memset(dp, -1, sizeof dp);

    cout << dfs(1, 1, 0);

}

 

int main(int argc, char const *argv[]){

    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

    ll t = 1;

    //cin >> t;

    while(t--){

        solve();

    }

}

// nEro

// Optimized solution to the same problem (faster):
//                                      KiSmAt

#include "bits/stdc++.h"

using namespace std;

 

using ll = long long;

 

const ll inf = 1e18;

const int mod = 1e9 + 7;

const int N = 2 * 1e5 + 10;



ll res;

ll a[N], dp[N][2];



vector<ll> v[N];



inline ll add(ll x, ll y){  return  (x % mod + y % mod) % mod;}

inline ll sub(ll x, ll y){  return  (x % mod - y % mod + mod) % mod;}

inline ll mul(ll x, ll y){  x %= mod;   y %= mod;   return 1LL * x * y % mod;}



void dfs(ll u, ll par){

    dp[u][0] = dp[u][1] = 1;

    for(auto i: v[u]){

        if(i != par){

            dfs(i, u);

            dp[u][0] = mul(dp[u][0], dp[i][1]);

            dp[u][1] = mul(dp[u][1], add(dp[i][0], dp[i][1]));

        }

    }

}



void solve(){

    ll n, x, y;

    cin >> n;

    for(int i = 0; i < n - 1; ++i){

        cin >> x >> y;

        v[x].push_back(y);

        v[y].push_back(x);

    }

    dfs(1, 1);

    cout << add(dp[1][0], dp[1][1]);

}

 

int main(int argc, char const *argv[]){

    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

    ll t = 1;

    //cin >> t;

    while(t--){

        solve();

    }

}

// nEro

// Fastest known solution for this problem:
// Original C++ solution (slower):
// We only fail when we stop trying

#include <bits/stdc++.h>

using namespace std;

#define pb push_back

#define mp make_pair

#define endl '\n'

#define D(x) cerr << #x << " = " << (x) << '\n'

#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

typedef long long ll;



const int N = 1e5 + 5;

const int Mod = 1e9 + 7;





int n;

vector<int> g[N];

int dp[N][2];



int dfs(int u, int p, int col) {

  int& r  = dp[u][col];

  if(r != -1) return r;

  r = 1;

  for(int v : g[u]) {

    if(v != p) {

      if(col == 0) { // b

        r = (1LL * r * dfs(v, u, 1)) % Mod;

      } else { // w

        r = (1LL * r * (dfs(v, u, 0) + dfs(v, u, 1))) % Mod;

      }

    }

  }

  return r;

}



int main()

{

  cin >> n;

  for(int i = 0; i < n - 1; i++) {

    int x, y;

    cin >> x >> y;

    --x, --y;

    g[x].pb(y);

    g[y].pb(x);

  }

  memset(dp, -1, sizeof dp);

  cout << (dfs(0, -1, 1) + dfs(0, -1, 0)) % Mod << endl;

  return 0;

}


// Optimized solution to the same problem (faster):
// We only fail when we stop trying

#include <bits/stdc++.h>

using namespace std;

#define pb push_back

#define mp make_pair

#define endl '\n'

#define D(x) cerr << #x << " = " << (x) << '\n'

#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

typedef long long ll;



const int N = 1e5 + 5;

const int Mod = 1e9 + 7;





int n;

vector<int> g[N];

int dp[N][2];



void dfs(int u, int p) {

  dp[u][0] = dp[u][1] = 1;

  for(int v : g[u]) {

    if(v != p) {

      dfs(v, u);

      dp[u][0] = (1LL * dp[u][0] * dp[v][1]) % Mod;

      dp[u][1] = (1LL * dp[u][1] * (dp[v][0] + dp[v][1])) % Mod;

    }

  }

}



int main()

{

  cin >> n;

  for(int i = 0; i < n - 1; i++) {

    int x, y;

    cin >> x >> y;

    --x, --y;

    g[x].pb(y);

    g[y].pb(x);

  }

  dfs(0, -1);

  int ans = (dp[0][0] + dp[0][1]) % Mod;

  cout << ans << endl;

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;



typedef long long llt;



const int MaxN = 100000 + 5, MaxM = 200000 + 5;

const llt Mod = 1e9 + 7;



int N; int cnte;

int Head[MaxN], To[MaxM], Next[MaxM];

int fa[MaxN];

llt dp[MaxN][2];



inline void add_edge(int from, int to) {

  cnte++; To[cnte] = to;

  Next[cnte] = Head[from]; Head[from] = cnte;

}



void init() {

  scanf("%d", &N);

  for (int i = 1; i < N; ++i) {

    int u, v;

    scanf("%d %d", &u, &v);

    add_edge(u, v); add_edge(v, u);

  }

}



void dfs(int u) {

  dp[u][0] = dp[u][1] = 1;

  for (int i = Head[u]; i; i = Next[i]) {

    int v = To[i];

    if (v == fa[u]) continue;

    fa[v] = u;

    dfs(v);



    dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % Mod;

    dp[u][1] = dp[u][1] * dp[v][0] % Mod;

  }

}



void solve() {

  dfs(1);

  llt ans = (dp[1][0] + dp[1][1]) % Mod;

  cout << ans << endl;

}



int main() {

  init();

  solve();

  return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



const int MaxN = 100000 + 5;

const int Mod = 1000000007;



struct Graph {

  int cnte;

  int Head[MaxN], To[MaxN * 2], Next[MaxN * 2];



  inline void addEdge(int from, int to) {

    cnte++; To[cnte] = to;

    Next[cnte] = Head[from]; Head[from] = cnte;

  }

};



int N;

int Dp[MaxN][2];

Graph G;



inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }

inline int mul(int x, int y) { return 1LL * x * y % Mod; }



void init() {

  scanf("%d", &N);

  for (int i = 1; i < N; ++i) {

    int u, v;

    scanf("%d %d", &u, &v);

    G.addEdge(u, v);

    G.addEdge(v, u);

  }

}



void dfs(int u, int f) {

  Dp[u][0] = Dp[u][1] = 1;

  for (int i = G.Head[u]; i; i = G.Next[i]) {

    int v = G.To[i];

    if (v == f) continue;

    dfs(v, u);

    Dp[u][0] = mul(Dp[u][0], add(Dp[v][0], Dp[v][1]));

    Dp[u][1] = mul(Dp[u][1], Dp[v][0]);

  }

}



void solve() {

  dfs(1, 0);

  printf("%d\n", add(Dp[1][0], Dp[1][1]));

}



int main() {

  init();

  solve();

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define ll long long

#define pu_b push_back



using namespace std;



const int N=1e5+10, Mod=1e9+7;

int n, max_floor=0;

ll dp[2][N];

int dis[N], par[N];

bool visible[N]={};

vector<int> adj[N], flor[N];



void dfs(int x){

    for(int v:adj[x]){

        if(visible[v]) continue;

        visible[v]=1;

        dis[v]=dis[x]+1;

        flor[dis[v]].pu_b(v);

        max_floor=max(max_floor, dis[v]);

        par[v]=x;

        dfs(v);

    }

}



int main()

{

    cin>>n;

    for(int i=0; i<n-1; i++){

        int x, y;

        cin>>x>>y;

        x--; y--;

        adj[x].pu_b(y);

        adj[y].pu_b(x);

    }

    dis[0]=0;

    visible[0]=1;

    flor[0].pu_b(0);

    dfs(0);

    //Computing dp

    int t=max_floor;

    for(int u:flor[max_floor]){

        dp[0][u]=1;

        dp[1][u]=2;

    }

    for(int i=max_floor-1; i>=0; i--){

        for(int p:flor[i]){

            ll blval=1, whval=1;

            for(int v:adj[p]){

                if(v!=par[p]){

                    blval=(blval*dp[0][v])%Mod;

                    whval=(whval*dp[1][v])%Mod;

                }

            }

            dp[0][p]=whval;

            dp[1][p]=(blval+whval)%Mod;

        }

    }

    cout<<dp[1][0];

}
















































// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define ll long long

#define PuB push_back



using namespace std;



const int N=1e5+10, Mod=1e9+7;

int n;

ll dp[2][N];

int par[N];

bool visible[N]={};

vector<int> adj[N];



void dfs(int x){

    bool leaf=1;

    for(int v:adj[x]){

        if(v!=par[x]){

            leaf=0;

            if(visible[v]) continue;

            par[v]=x;

            visible[v]=1;

            dfs(v);

        }

    }

    if(leaf){

        dp[0][x]=1;

        dp[1][x]=2;

        return;

    }

    ll blval=1, whval=1;

    for(int u:adj[x]){

        if(u!=par[x]){

            blval*=dp[0][u];

            blval%=Mod;

            whval*=dp[1][u];

            whval%=Mod;

        }

    }

    dp[0][x]=whval;

    dp[1][x]=(whval+blval)%Mod;

}



int main()

{

    cin>>n;

    for(int i=0; i<n-1; i++){

        int x, y;

        cin>>x>>y;

        x--; y--;

        adj[x].PuB(y);

        adj[y].PuB(x);

    }

    par[0]=-1;

    visible[0]=1;

    dfs(0);

    cout<<dp[1][0];

}
















































// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#ifdef LOCAL

        ifstream in("input.txt");

        //ofstream out("output.txt");

        #define cin in

        //#define cout out

#endif

int const MAXN=110000, M=1000000007;

long long int bianco[MAXN], nero[MAXN], n;

vector<int> g[MAXN], t[MAXN];

void make_tree(int node=1, int parent=-1){

	for(auto x:g[node])

		if(x!=parent){

			t[node].push_back(x);

			make_tree(x,node);

		}

}

void dp(int node=1){

	if(t[node].empty()){

		bianco[node]=1LL;

		nero[node]=1LL;

	}

	else{

		for(auto x:t[node])

			dp(x);

		nero[node]=1LL;

		for(auto x:t[node]){

			nero[node]*=bianco[x];

			nero[node]%=M;

		}

		bianco[node]=1LL;

		for(auto x:t[node]){

			bianco[node]*=nero[x]+bianco[x];

			bianco[node]%=M;

		}

	}

}

int main(){

	cin>>n;

	for(int i=0;i<n-1;i++){

		int from, to;

		cin>>from>>to;

		g[from].push_back(to);

		g[to].push_back(from);

	}

	make_tree();

	dp();

	cout<<(nero[1]+bianco[1])%M;

}

// Optimized solution to the same problem (faster):
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

void dbg_out(){

	cerr<<endl;

}

template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){

	cerr<<' '<< H; 

	dbg_out(T...);

}

int const MAXN=100100, MOD=1e9+7;

#define ll long long

vector<int> tree[MAXN];

ll w[MAXN], b[MAXN], n;

void dp(int node, int parent){

	w[node]=b[node]=1;

	for(int x:tree[node])

		if(x!=parent){

			dp(x,node);

			b[node]=(b[node]*w[x])%MOD;

			w[node]=((w[x]+b[x])%MOD*w[node])%MOD;

		}

	//dbg(node,parent,b[node],w[node]);	

}

int main(){

	cin>>n;

	for(int i=0;i<n-1;i++){

		int a, b;

		cin>>a>>b;

		tree[a].push_back(b);

		tree[b].push_back(a);

	}

	dp(1,0);

	cout<<(w[1]+b[1])%MOD;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std ;

#define ll long long 

vector<int> edges[100005];

int mod=1e9+7;

ll mul(ll a,ll b){

	return a*b%mod;

}

pair<ll,ll> dfs(int a,int parent){

	ll allwhite=1;

	ll smblack=0;

	for(auto b:edges[a]){

		if(b!=parent){

			pair<ll,ll>p=dfs(b,a);

		

		smblack= (mul(allwhite,p.first)+mul(smblack,p.first+p.second))%mod;

		allwhite*=p.second;

		allwhite%=mod;

		}

	}

	return{allwhite,(allwhite+smblack)%mod};

}



int main(){

	ll n;

	cin>>n;

	for(int i=0;i<n-1;i++){

		int a,b;

		cin>>a>>b;

		edges[a].push_back(b);

		edges[b].push_back(a);

	}

	pair<ll,ll>p=dfs(1,-1);

	

	cout<<(p.first+p.second)%mod;

	

	

	

	

	return 0;

	

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int mod=1e9+7;

vector<vector<int>>adj;

pair<ll,ll> dfs(int i,int p){

    ll all_white=1;

    ll sm_black=0;

    for(int u:adj[i]){

        if(u!=p){

            pair<ll,ll>p=dfs(u,i);

            sm_black=(all_white*p.first%mod+sm_black*(p.first+p.second)%mod)%mod;

            all_white=all_white*p.second%mod;



        }

    }

    return{all_white,all_white+sm_black};



}



int main(){

    int n;

    cin>>n;

    adj=vector<vector<int>>(n+1);

    int x,y;

    for(int i=0;i<n-1;i++){

        cin>>x>>y;

        adj[x].push_back(y);

        adj[y].push_back(x);

    }

    pair<ll,ll>p=dfs(1,-1);

    cout<<(p.first+p.second)%mod;

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



const int N = 1e5 + 5;

long long dp[N][2];

vector<int>a[N];

const int m = 1e9 + 7;

long long solve(int u, int c, int p){

    if(dp[u][c] != -1) return dp[u][c];

    long long ans = 1;

    for(auto v : a[u]){

        if(v == p) continue;

        if(c == 0){

            ans = (ans *(solve(v, 0, u) + solve(v, 1, u)) )%m;

        }

        else ans = (ans * solve(v, 0, u)) % m;

    }

    dp[u][c] = ans;

    return ans;

}

int main(){

    int n, x, y;

    cin >> n;

    for(int i = 1; i < n; i++){

        cin >> x >> y;

        x --, y --;

        a[x].push_back(y);

        a[y].push_back(x);

    }

    memset(dp, -1, sizeof(dp));

    long long ans = (solve(0, 0, -1) + solve(0, 1, -1))%m;

    cout << ans << "\n";

    return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



const int N = 1e5 + 5;

long long dp[N];

vector<int>a[N];

vector<bool>isvisited(N, false);

const int m = 1e9 + 7;

long long solve(int u,int p){

    if(dp[u] != -1)return dp[u];

    long long ans1 = 1,ans2 = 1;

    for(auto v: a[u]){

        if(v == p) continue;

        ans1 = (ans1 * solve(v, u)) % m;

        for(auto w : a[v]){

            if(w == u) continue;

            ans2 = (ans2 * solve(w,v)) % m;

        }

    }

    dp[u] = (ans1 + ans2)%m;

    return dp[u];

}

int main(){

    int n, x, y;

    cin >> n;

    for(int i = 1; i < n; i++){

        cin >> x >> y;

        x --, y --;

        a[x].push_back(y);

        a[y].push_back(x);

    }

    memset(dp, -1, sizeof(dp));  

    solve(0, -1);

    cout << dp[0] << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<ll> vec;

typedef vector<vec> mat;

typedef pair<ll,ll> pll;

const ll mod=1e9+7;

//const ll mod=998244353;

const ll inf=5e15;



const ll N=1e5+10;

vector<set<ll>> G(N);

vec b(N),w(N);

ll n;



void dfs(ll cur,ll pre) {

  b[cur]=1,w[cur]=1;

  for(ll nex:G[cur]) {

    if(nex==pre) continue;

    dfs(nex,cur);

    (b[cur]*=w[nex])%=mod;

    (w[cur]*=(w[nex]+b[nex])%mod)%=mod;

  }

}

 

int main() {

  cin >> n;

  for(ll i=1;i<n;i++) {

    ll x,y;

    cin >> x >> y;

    x--,y--;

    G[x].insert(y);

    G[y].insert(x);

  }

  dfs(0,-1);

  cout << (b[0]+w[0])%mod << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<ll> vec;

typedef vector<vec> mat;

typedef pair<ll,ll> pll;

const ll mod=1e9+7;

//const ll mod=998244353;

const ll inf=1LL<<61;



const ll N=1e5+10;

mat G(N);

vec w(N),b(N);



void dfs(ll cur,ll pre) {

  w[cur]=1,b[cur]=1;

  for(ll nex:G[cur]) {

    if(nex==pre) continue;

    dfs(nex,cur);

    (b[cur]*=w[nex])%=mod;

    (w[cur]*=w[nex]+b[nex])%=mod;

  }

}



int main() {

  ll n;

  cin >> n;

  for(ll i=0;i<n-1;i++) {

    ll x,y;

    cin >> x >> y;

    x--,y--;

    G[x].push_back(y);

    G[y].push_back(x);

  }

  dfs(0,-1);

  cout << (w[0]+b[0])%mod << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*#include <bits/stdc++.h>

using namespace std;

long long n;

vector<long long>v[100009];

long long mod = 1000000007;

long long dp[100009][3];

void dfs(int node,int p){

	dp[node][0] = dp[node][1] = 1;

	for(int i=0;i<v[node].size();i++){

		int u = v[node][i];

		if(u == p)continue;

		dfs(u,node);

		dp[node][0] = (dp[node][0] * (dp[u][0] + dp[u][1])%mod)%mod;

		dp[node][1] = (dp[node][1] * dp[u][0])%mod;

	}

}

int main(){

	cin>>n;

	for(int i=0;i<n-1;i++){

		int a,b;

		cin>>a>>b;

		a--;b--;

		v[a].push_back(b);

		v[b].push_back(a);

	}

	dfs(0,0);

	cout<<dp[0][0] + dp[0][1]<<endl;

}*/

#include <bits/stdc++.h>

using namespace std;

long long n;

vector<long long>v[100009];

long long dp[100009][3];

long long mod=1000000007;

long long bt(int node,int p,int t){

	long long &ret=dp[node][t];

	if(ret!=-1)return ret;

	ret=1;

	for(int i=0;i<v[node].size();i++){

		int u=v[node][i];

		if(u==p)continue;

		if(t==1)ret=(ret%mod*bt(u,node,0)%mod)%mod;

		else if(t==0)ret=(ret%mod*(bt(u,node,1)%mod+bt(u,node,0)%mod)%mod)%mod;

	}

	return ret%mod;

}

int main(){

	memset(dp,-1,sizeof(dp));

	cin>>n;

	for(int i=0;i<n-1;i++){

		int a,b;

		cin>>a>>b;

		a--;b--;

		v[a].push_back(b);

		v[b].push_back(a);

	}

	cout<<(bt(0,0,0)%mod+bt(0,0,1)%mod)%mod<<endl;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

long long n;

vector<long long>v[100009];

long long mod = 1000000007;

long long dp[100009][3];

void dfs(int node,int p){

 	dp[node][0] = dp[node][1] = 1;

   	for(int i=0;i<v[node].size();i++){

   		int u = v[node][i];

   		if(u == p)continue;

   		dfs(u,node);

   		dp[node][0] = (dp[node][0] * (dp[u][0] + dp[u][1])%mod)%mod;

   		dp[node][1] = (dp[node][1] * dp[u][0])%mod;

   	}

}

int main(){

   	cin>>n;

   	for(int i=0;i<n-1;i++){

   		int a,b;

   		cin>>a>>b;

   		a--;b--;

   		v[a].push_back(b);

   		v[b].push_back(a);

   	}

   	dfs(0,0);

   	cout<<(dp[0][0] + dp[0][1]) % mod<<endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int mod = 1e9 + 7, mxN = 1e5 + 5, mxC = 2;

int N;

vector<int> adj[mxN];

ll dp[mxN][mxC];



ll rec(int v, int p, int pcol) {

	if (dp[v][pcol] != -1)

		return dp[v][pcol];

	ll tot = 0, ways = 1;

	if (pcol == 0) {

		for (auto it : adj[v]) {

			if (it != p) {

				ways = (ways * rec(it, v, 1)) % mod;

			}

		}

		tot = ways;

	}

	ways = 1;

	for (auto it : adj[v]) {

		if (it != p) {

			ways = (ways * rec(it, v, 0)) % mod;

		}

	}

	tot = (tot + ways) % mod;

	return dp[v][pcol] = tot;

}



int main() {

	ios_base::sync_with_stdio(false);



	cin >> N;

	for (int i = 0; i < N - 1; i++) {

		int x, y;

		cin >> x >> y;

		adj[x].push_back(y);

		adj[y].push_back(x);

	}

	memset(dp, -1, sizeof(dp));

	ll answer = rec(1, 0, 0);

	cout << answer;



	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int mxN = 1e5 + 5, mod = 1e9 + 7;

int N;

vector<int> adj[mxN];

int dp[mxN][2];



int rec(int u, int p, int pc) {

	if (dp[u][pc] != -1) {

		return dp[u][pc];

	}

	ll tot = 0, ways = 1;

	if (pc == 0) {

		for (int v : adj[u]) {

			if (v == p) {

				continue;

			}

			ways = (ways * rec(v, u, 1)) % mod;

		}

		tot = ways;

	}

	ways = 1;

	for (int v : adj[u]) {

		if (v == p) {

			continue;

		}

		ways = (ways * rec(v, u, 0)) % mod;

	}

	tot = (tot + ways) % mod;

	return dp[u][pc] = tot;

}



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(0);

	

	cin >> N;

	int x, y;

	for (int i = 0; i < N - 1; i++) {

		cin >> x >> y;

		x--, y--;

		adj[x].push_back(y);

		adj[y].push_back(x);

	}

	memset(dp, -1, sizeof(dp));

	int ans = rec(0, -1, 0);

	cout << ans;

	

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7;

const long long OO = 1e18+25;

#define par pair<pair<int,int>, int>

#define f first

#define s second



int n, mem[N][2], u,v,vis[N][2];

vector <int> g[N];



long long dp(int ele=1, int precol=0)

{

    int &ret= mem[ele][precol];

    if(vis[ele][precol] && ret == -1) return 1;

    if(~ret) return ret;

    vis[ele][precol] = 1;

    int ans=0, ans1=1;

    if(!precol) ans =1;

    for(int e : g[ele])

    {

        vis[ele][1] ^= 2;

        ans1 = (1ll*ans1*dp(e, 0))%oo;

        vis[ele][1] ^= 2;

        if(!precol) ans = (1ll*ans*dp(e, 1))%oo;

    }

    ret = (ans+ans1)%oo;

    return ret;

}



int main()

{

    memset(mem, -1, sizeof mem);

    scanf("%d",&n);

    for(int i=0; i<n-1; i++) {scanf("%d%d",&u,&v);g[u].push_back(v);g[v].push_back(u);}

    printf("%lld",dp());

    return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<cstdio>

using namespace std;

typedef long long ll;

const int Maxn=1e5+5;

const int Mod=1e9+7;

struct edge{

	int v,nx;

}e[Maxn<<1];

int n,ne,f[Maxn];

ll dp[Maxn][2];

void read(int u,int v)

{	e[++ne].v=v;

	e[ne].nx=f[u];

	f[u]=ne;

}

void dfs(int u,int fa)

{	dp[u][0]=dp[u][1]=1ll;

	for(int i=f[u];i;i=e[i].nx)

	{	int v=e[i].v;

		if(v==fa)continue;

		dfs(v,u);

		dp[u][0]=((dp[v][1]+dp[v][0])%Mod*dp[u][0])%Mod;

		dp[u][1]=(dp[u][1]*dp[v][0])%Mod;

	}

}

int main()

{	scanf("%d",&n);

	for(int i=1;i<n;i++)

	{	int u,v;

		scanf("%d%d",&u,&v);

		read(u,v);read(v,u);

	}

	dfs(1,0);

	printf("%lld\n",(dp[1][0]+dp[1][1])%Mod);

	return 0;

}

// Fastest known solution for this problem: