stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



typedef long long int ll;

const ll maxn = 100010;

const ll mod = 1000000007;

vector <ll> adj[maxn];

ll dp[maxn][3];



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

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

    ll ans = 1;

    for(auto x: adj[node]){

        if(x != par){

            if(col == 1){

                ans *= dfs(x,0,node);

                ans %= mod;

            }

            else{

                ans = ans * (dfs(x,0,node) + dfs(x,1,node));

                ans %= mod;

            }

        }

    }



    return dp[node][col] = ans;

}

int main(){

    memset(dp,-1,sizeof dp);

    ll n;

    scanf("%lld",&n);



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

        ll u,v;

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

        adj[u].push_back(v);

        adj[v].push_back(u);

    }



    printf("%lld\n",(dfs(1,0,-1)+dfs(1,1,-1))%mod);

}


// Faster C++ solution for the same problem (measured speedup: 3.423829388710145x):
#include <bits/stdc++.h>



using namespace std;



// Header files, namespaces,

// macros as defined above

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;



#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>





#define f first

#define s second

#define db long double

#define pb push_back

#define sz(c) (c).size()

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



typedef long long ll;

typedef pair <int , int> ii;

typedef pair <ii , int> iii;

typedef vector <int> vi;

typedef vector <ii> vii;

typedef vector <iii> viii;

typedef vector <vi> vvi;

typedef vector <vii> vvii;



const ll mod = 1e9+7;

const int MAX = 1e5+5;

const db eps = 1e-13;



int memo[MAX][2];

int n;

vvi g;



int dp( int node, int color , int p = -1 ) {



    if( memo[node][color] != -1 )

        return memo[node][color];



    int &res = memo[node][color];

    res = 1;

    if( sz(g[node]) == 1 && p != -1 ) {



        return res = res + (!color);



    }



    ll res1 = 1;

    ll res2 = 1;



    for( int nw: g[node] ) {

        if( nw==p )

            continue;



        if( !color )

            res1 = ( 1ll * res1 * dp( nw , color , node ) ) % mod;

        res2 = ( 1ll * res2 * dp( nw , color^1 , node ) ) % mod;

    }

    return res = ((!color)*res1+res2)%mod;

}





int main()

{

	ios_base::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

    cout<<setprecision(11)<<fixed;



    memset( memo , -1 , sizeof memo );

    cin>>n;

    if( n==1 ) {

        cout<<2<<"\n";

        return 0;

    }



    vi v;

    g = vvi(n+1,v);

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

        int a, b;

        cin>>a>>b;

        g[a].pb(b);

        g[b].pb(a);

    }

    cout<<dp( 1 , 0 )<<"\n";



}

/*

10

8 5

10 8

6 5

1 5

4 8

2 10

3 6

9 2

1 7

*/
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



typedef long long int ll;

const ll maxn = 100010;

const ll mod = 1000000007;

vector <ll> adj[maxn];

ll dp[maxn][3];



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

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

    ll ans = 1;

    for(auto x: adj[node]){

        if(x != par){

            if(col == 1){

                ans *= dfs(x,0,node);

                ans %= mod;

            }

            else{

                ans = ans * (dfs(x,0,node) + dfs(x,1,node));

                ans %= mod;

            }

        }

    }



    return dp[node][col] = ans;

}

int main(){

    memset(dp,-1,sizeof dp);

    ll n;

    scanf("%lld",&n);



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

        ll u,v;

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

        adj[u].push_back(v);

        adj[v].push_back(u);

    }



    printf("%lld\n",(dfs(1,0,-1)+dfs(1,1,-1))%mod);

}


// Faster C++ solution for the same problem (measured speedup: 2.4126457579501266x):
#include<cstdio>

#include<iostream>

using namespace std;

const int MAXN = 100010;

const int MOD = 1e9+7;

int n;

struct edge{

	int next, to;

	edge(int N=0,int T=0):next(N),to(T){}

}e[MAXN<<1];

int fir[MAXN], num = 0;

inline void join(int a,int b){e[++num]=edge(fir[a],b);fir[a]=num;}

int f[MAXN][2];

void dfs(int u, int fa)

{

	f[u][0] =1ll; f[u][1] = 1ll;

	for(int i=fir[u];i;i=e[i].next)

	{

		int v = e[i].to;

		if(v == fa)continue;

		dfs(v, u);

		f[u][1] = 1ll*f[u][1]*f[v][0]%MOD;

		f[u][0] = 1ll*f[u][0]*(1ll*f[v][0]+f[v][1])%MOD; 

	}

}

int main()

{

	scanf("%d",&n);

	for(int i=1,a,b;i<n;i++)

		scanf("%d%d",&a,&b),join(a,b),join(b,a);

	dfs(1, 0);

	printf("%d\n",(1ll*f[1][0]+f[1][1])%MOD);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>     



//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4"



#define mp make_pair

#define pb push_back

#define f first

#define s second

#define ll long long

#define int ll

#define forn(i, a, b) for(int i = (a); i <= (b); ++i)

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

#define VAR(v, i) __typeof( i) v=(i)

#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

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

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

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

 

using namespace std;

 

const int maxn = (int)1e5+100;

const int mod = (int)1e9 + 7;

 

#define inf mod

 

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;   

typedef vector<ll> Vll;               

typedef vector<pair<int, int> > vpii;

typedef vector<pair<ll, ll> > vpll;



int n, dp[maxn][2];

vi g[maxn];



void dfs(int v, int p = 0){

  dp[v][0]=dp[v][1]=1;

  for(auto to:g[v])

    if(to!=p){

      dfs(to,v);

      dp[v][0]=dp[v][0]*((dp[to][0]+dp[to][1])%mod)%mod;

      dp[v][1]=dp[v][1]*dp[to][0]%mod;

    }

}

main () {

  cin>>n;

  forn(i,1,n-1){

    int u, v;

    cin>>u>>v;

    g[u].pb(v);

    g[v].pb(u);

  }

  dfs(1);

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

}

// Faster C++ solution for the same problem (measured speedup: 1.3618210979463696x):
#include<cstdio>

#include<iostream>

using namespace std;

const int MAXN = 100010;

const int MOD = 1e9+7;

int n;

struct edge{

	int next, to;

	edge(int N=0,int T=0):next(N),to(T){}

}e[MAXN<<1];

int fir[MAXN], num = 0;

inline void join(int a,int b){e[++num]=edge(fir[a],b);fir[a]=num;}

int f[MAXN][2];

void dfs(int u, int fa)

{

	f[u][0] =1ll; f[u][1] = 1ll;

	for(int i=fir[u];i;i=e[i].next)

	{

		int v = e[i].to;

		if(v == fa)continue;

		dfs(v, u);

		f[u][1] = 1ll*f[u][1]*f[v][0]%MOD;

		f[u][0] = 1ll*f[u][0]*(1ll*f[v][0]+f[v][1])%MOD; 

	}

}

int main()

{

	scanf("%d",&n);

	for(int i=1,a,b;i<n;i++)

		scanf("%d%d",&a,&b),join(a,b),join(b,a);

	dfs(1, 0);

	printf("%d\n",(1ll*f[1][0]+f[1][1])%MOD);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h> 



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

 

#define nl '\n'

 

#define y1 aza_ibagaliev

 

#define f first

#define s second

	

#define ed end()

#define bg begin()

#define rbg rbegin()

 

#define rv reverse

#define mp make_pair

#define pb push_back

#define ppb pop_back

#define ppf pop_front

 

#define sz size()

#define all(x) x.bg, x.ed

 

#define pll pair < ll, ll >

#define pii pair < int, int >

 

#define sqr(x) ((x) * 1ll * (x))

#define sqrd(x) ((x) * 1.0 * (x))

 

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

 

#define rnl cout << "----------------------------------------" << nl

 

#define bit __builtin_popcount

 

inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

        	

const int ppr = 257;

const ll INF = 2e18;

const int inf = 2e9;

const int mod = 1e9 + 7;

const int N = 1e5 + 123;

const ld pi = 3.1741592653589793238462643;

 

const int dx[] = {1, 0, -1, 0};

const int dy[] = {0, 1, 0, -1};



ll n, dp[3][N];

vector<int>g[N];



void dfs(int v, int pr=0) {

	dp[0][v] = dp[1][v] = 1;



	for(int to : g[v]) {

		if(to == pr) continue;

		dfs(to, v);	

		dp[0][v] = (dp[0][v] * (dp[0][to] + dp[1][to])) % mod;

		dp[1][v] = (dp[1][v] * dp[0][to]) % mod;

	}

}



main() {             	

//  freopen(".in", "r", stdin);

//  freopen(".out", "w", stdout);



//	srand(time(NULL));



	scanf("%d", &n);



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

		int x, y;

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

		g[x].pb(y);

		g[y].pb(x);

	}



	dfs(1);



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

    

    return 0;                                        

}

// Faster C++ solution for the same problem (measured speedup: 1.3584119401537016x):
#include<cstdio>

#include<iostream>

using namespace std;

const int MAXN = 100010;

const int MOD = 1e9+7;

int n;

struct edge{

	int next, to;

	edge(int N=0,int T=0):next(N),to(T){}

}e[MAXN<<1];

int fir[MAXN], num = 0;

inline void join(int a,int b){e[++num]=edge(fir[a],b);fir[a]=num;}

int f[MAXN][2];

void dfs(int u, int fa)

{

	f[u][0] =1ll; f[u][1] = 1ll;

	for(int i=fir[u];i;i=e[i].next)

	{

		int v = e[i].to;

		if(v == fa)continue;

		dfs(v, u);

		f[u][1] = 1ll*f[u][1]*f[v][0]%MOD;

		f[u][0] = 1ll*f[u][0]*(1ll*f[v][0]+f[v][1])%MOD; 

	}

}

int main()

{

	scanf("%d",&n);

	for(int i=1,a,b;i<n;i++)

		scanf("%d%d",&a,&b),join(a,b),join(b,a);

	dfs(1, 0);

	printf("%d\n",(1ll*f[1][0]+f[1][1])%MOD);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



typedef long long int ll;

const ll maxn = 100010;

const ll mod = 1000000007;

vector <ll> adj[maxn];

ll dp[maxn][3];



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

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

    ll ans = 1;

    for(auto x: adj[node]){

        if(x != par){

            if(col == 1){

                ans *= dfs(x,0,node);

                ans %= mod;

            }

            else{

                ans = ans * (dfs(x,0,node) + dfs(x,1,node));

                ans %= mod;

            }

        }

    }



    return dp[node][col] = ans;

}

int main(){

    memset(dp,-1,sizeof dp);

    ll n;

    scanf("%lld",&n);



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

        ll u,v;

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

        adj[u].push_back(v);

        adj[v].push_back(u);

    }



    printf("%lld\n",(dfs(1,0,-1)+dfs(1,1,-1))%mod);

}


// Faster C++ solution for the same problem (measured speedup: 6.165542357578507x):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define ll long long

#define MOD 1000000007



class grafo {

	int n;

	vector<vector<pair<int, int>>> adj;



public:



    vector<ll> dp_preto, dp_branco;



	grafo(int n) {

		this->n = n;

		adj = vector<vector<pair<int, int>>>(n);

        dp_preto = vector<ll>(n, 1);

        dp_branco = vector<ll>(n, 1);

	}



	void aresta(int u, int v, int w) {

		adj[u].pb({v, w});

		adj[v].pb({u, w});

	}



    void dfs(int u, int pai = -1) {

        for (auto &v : adj[u]) {

            if (v.first == pai) continue;

            dfs(v.first, u);

            dp_branco[u] *= (dp_preto[v.first] + dp_branco[v.first]);

            dp_preto[u] *= dp_branco[v.first];

            dp_branco[u] %= MOD;

            dp_preto[u] %= MOD;

        }

	}



};



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n, x, y;

    cin >> n;

    grafo g(n);

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

        cin >> x >> y;

        g.aresta(x-1, y-1, 1);

    }

    g.dfs(0);

    cout << (g.dp_preto[0] + g.dp_branco[0]) % MOD;

}
// Slower C++ solution:
#include <bits/stdc++.h>     



//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4"



#define mp make_pair

#define pb push_back

#define f first

#define s second

#define ll long long

#define int ll

#define forn(i, a, b) for(int i = (a); i <= (b); ++i)

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

#define VAR(v, i) __typeof( i) v=(i)

#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

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

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

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

 

using namespace std;

 

const int maxn = (int)1e5+100;

const int mod = (int)1e9 + 7;

 

#define inf mod

 

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;   

typedef vector<ll> Vll;               

typedef vector<pair<int, int> > vpii;

typedef vector<pair<ll, ll> > vpll;



int n, dp[maxn][2];

vi g[maxn];



void dfs(int v, int p = 0){

  dp[v][0]=dp[v][1]=1;

  for(auto to:g[v])

    if(to!=p){

      dfs(to,v);

      dp[v][0]=dp[v][0]*((dp[to][0]+dp[to][1])%mod)%mod;

      dp[v][1]=dp[v][1]*dp[to][0]%mod;

    }

}

main () {

  cin>>n;

  forn(i,1,n-1){

    int u, v;

    cin>>u>>v;

    g[u].pb(v);

    g[v].pb(u);

  }

  dfs(1);

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

}

// Faster C++ solution for the same problem (measured speedup: 3.4801485610412506x):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define ll long long

#define MOD 1000000007



class grafo {

	int n;

	vector<vector<pair<int, int>>> adj;



public:



    vector<ll> dp_preto, dp_branco;



	grafo(int n) {

		this->n = n;

		adj = vector<vector<pair<int, int>>>(n);

        dp_preto = vector<ll>(n, 1);

        dp_branco = vector<ll>(n, 1);

	}



	void aresta(int u, int v, int w) {

		adj[u].pb({v, w});

		adj[v].pb({u, w});

	}



    void dfs(int u, int pai = -1) {

        for (auto &v : adj[u]) {

            if (v.first == pai) continue;

            dfs(v.first, u);

            dp_branco[u] *= (dp_preto[v.first] + dp_branco[v.first]);

            dp_preto[u] *= dp_branco[v.first];

            dp_branco[u] %= MOD;

            dp_preto[u] %= MOD;

        }

	}



};



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n, x, y;

    cin >> n;

    grafo g(n);

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

        cin >> x >> y;

        g.aresta(x-1, y-1, 1);

    }

    g.dfs(0);

    cout << (g.dp_preto[0] + g.dp_branco[0]) % MOD;

}
// Slower C++ solution:
#include <bits/stdc++.h> 



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

 

#define nl '\n'

 

#define y1 aza_ibagaliev

 

#define f first

#define s second

	

#define ed end()

#define bg begin()

#define rbg rbegin()

 

#define rv reverse

#define mp make_pair

#define pb push_back

#define ppb pop_back

#define ppf pop_front

 

#define sz size()

#define all(x) x.bg, x.ed

 

#define pll pair < ll, ll >

#define pii pair < int, int >

 

#define sqr(x) ((x) * 1ll * (x))

#define sqrd(x) ((x) * 1.0 * (x))

 

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

 

#define rnl cout << "----------------------------------------" << nl

 

#define bit __builtin_popcount

 

inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

        	

const int ppr = 257;

const ll INF = 2e18;

const int inf = 2e9;

const int mod = 1e9 + 7;

const int N = 1e5 + 123;

const ld pi = 3.1741592653589793238462643;

 

const int dx[] = {1, 0, -1, 0};

const int dy[] = {0, 1, 0, -1};



ll n, dp[3][N];

vector<int>g[N];



void dfs(int v, int pr=0) {

	dp[0][v] = dp[1][v] = 1;



	for(int to : g[v]) {

		if(to == pr) continue;

		dfs(to, v);	

		dp[0][v] = (dp[0][v] * (dp[0][to] + dp[1][to])) % mod;

		dp[1][v] = (dp[1][v] * dp[0][to]) % mod;

	}

}



main() {             	

//  freopen(".in", "r", stdin);

//  freopen(".out", "w", stdout);



//	srand(time(NULL));



	scanf("%d", &n);



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

		int x, y;

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

		g[x].pb(y);

		g[y].pb(x);

	}



	dfs(1);



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

    

    return 0;                                        

}

// Faster C++ solution for the same problem (measured speedup: 3.471436421389128x):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define ll long long

#define MOD 1000000007



class grafo {

	int n;

	vector<vector<pair<int, int>>> adj;



public:



    vector<ll> dp_preto, dp_branco;



	grafo(int n) {

		this->n = n;

		adj = vector<vector<pair<int, int>>>(n);

        dp_preto = vector<ll>(n, 1);

        dp_branco = vector<ll>(n, 1);

	}



	void aresta(int u, int v, int w) {

		adj[u].pb({v, w});

		adj[v].pb({u, w});

	}



    void dfs(int u, int pai = -1) {

        for (auto &v : adj[u]) {

            if (v.first == pai) continue;

            dfs(v.first, u);

            dp_branco[u] *= (dp_preto[v.first] + dp_branco[v.first]);

            dp_preto[u] *= dp_branco[v.first];

            dp_branco[u] %= MOD;

            dp_preto[u] %= MOD;

        }

	}



};



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n, x, y;

    cin >> n;

    grafo g(n);

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

        cin >> x >> y;

        g.aresta(x-1, y-1, 1);

    }

    g.dfs(0);

    cout << (g.dp_preto[0] + g.dp_branco[0]) % MOD;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



// Header files, namespaces,

// macros as defined above

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;



#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>





#define f first

#define s second

#define db long double

#define pb push_back

#define sz(c) (c).size()

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



typedef long long ll;

typedef pair <int , int> ii;

typedef pair <ii , int> iii;

typedef vector <int> vi;

typedef vector <ii> vii;

typedef vector <iii> viii;

typedef vector <vi> vvi;

typedef vector <vii> vvii;



const ll mod = 1e9+7;

const int MAX = 1e5+5;

const db eps = 1e-13;



int memo[MAX][2];

int n;

vvi g;



int dp( int node, int color , int p = -1 ) {



    if( memo[node][color] != -1 )

        return memo[node][color];



    int &res = memo[node][color];

    res = 1;

    if( sz(g[node]) == 1 && p != -1 ) {



        return res = res + (!color);



    }



    ll res1 = 1;

    ll res2 = 1;



    for( int nw: g[node] ) {

        if( nw==p )

            continue;



        if( !color )

            res1 = ( 1ll * res1 * dp( nw , color , node ) ) % mod;

        res2 = ( 1ll * res2 * dp( nw , color^1 , node ) ) % mod;

    }

    return res = ((!color)*res1+res2)%mod;

}





int main()

{

	ios_base::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

    cout<<setprecision(11)<<fixed;



    memset( memo , -1 , sizeof memo );

    cin>>n;

    if( n==1 ) {

        cout<<2<<"\n";

        return 0;

    }



    vi v;

    g = vvi(n+1,v);

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

        int a, b;

        cin>>a>>b;

        g[a].pb(b);

        g[b].pb(a);

    }

    cout<<dp( 1 , 0 )<<"\n";



}

/*

10

8 5

10 8

6 5

1 5

4 8

2 10

3 6

9 2

1 7

*/

// Faster C++ solution for the same problem (measured speedup: 1.8007738288329969x):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define ll long long

#define MOD 1000000007



class grafo {

	int n;

	vector<vector<pair<int, int>>> adj;



public:



    vector<ll> dp_preto, dp_branco;



	grafo(int n) {

		this->n = n;

		adj = vector<vector<pair<int, int>>>(n);

        dp_preto = vector<ll>(n, 1);

        dp_branco = vector<ll>(n, 1);

	}



	void aresta(int u, int v, int w) {

		adj[u].pb({v, w});

		adj[v].pb({u, w});

	}



    void dfs(int u, int pai = -1) {

        for (auto &v : adj[u]) {

            if (v.first == pai) continue;

            dfs(v.first, u);

            dp_branco[u] *= (dp_preto[v.first] + dp_branco[v.first]);

            dp_preto[u] *= dp_branco[v.first];

            dp_branco[u] %= MOD;

            dp_preto[u] %= MOD;

        }

	}



};



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n, x, y;

    cin >> n;

    grafo g(n);

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

        cin >> x >> y;

        g.aresta(x-1, y-1, 1);

    }

    g.dfs(0);

    cout << (g.dp_preto[0] + g.dp_branco[0]) % MOD;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

using namespace std;

const int MAXN = 100010;

const int MOD = 1e9+7;

int n;

struct edge{

	int next, to;

	edge(int N=0,int T=0):next(N),to(T){}

}e[MAXN<<1];

int fir[MAXN], num = 0;

inline void join(int a,int b){e[++num]=edge(fir[a],b);fir[a]=num;}

int f[MAXN][2];

void dfs(int u, int fa)

{

	f[u][0] =1ll; f[u][1] = 1ll;

	for(int i=fir[u];i;i=e[i].next)

	{

		int v = e[i].to;

		if(v == fa)continue;

		dfs(v, u);

		f[u][1] = 1ll*f[u][1]*f[v][0]%MOD;

		f[u][0] = 1ll*f[u][0]*(1ll*f[v][0]+f[v][1])%MOD; 

	}

}

int main()

{

	scanf("%d",&n);

	for(int i=1,a,b;i<n;i++)

		scanf("%d%d",&a,&b),join(a,b),join(b,a);

	dfs(1, 0);

	printf("%d\n",(1ll*f[1][0]+f[1][1])%MOD);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.55551082758912x):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define ll long long

#define MOD 1000000007



class grafo {

	int n;

	vector<vector<pair<int, int>>> adj;



public:



    vector<ll> dp_preto, dp_branco;



	grafo(int n) {

		this->n = n;

		adj = vector<vector<pair<int, int>>>(n);

        dp_preto = vector<ll>(n, 1);

        dp_branco = vector<ll>(n, 1);

	}



	void aresta(int u, int v, int w) {

		adj[u].pb({v, w});

		adj[v].pb({u, w});

	}



    void dfs(int u, int pai = -1) {

        for (auto &v : adj[u]) {

            if (v.first == pai) continue;

            dfs(v.first, u);

            dp_branco[u] *= (dp_preto[v.first] + dp_branco[v.first]);

            dp_preto[u] *= dp_branco[v.first];

            dp_branco[u] %= MOD;

            dp_preto[u] %= MOD;

        }

	}



};



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n, x, y;

    cin >> n;

    grafo g(n);

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

        cin >> x >> y;

        g.aresta(x-1, y-1, 1);

    }

    g.dfs(0);

    cout << (g.dp_preto[0] + g.dp_branco[0]) % MOD;

}