#include using namespace std; using ll = long long; const ll mod = 1e9 + 7; ll n, root; vector> hen; vector dp; pair dfs(ll v, ll par) { ll sum = 0; ll cnt = 1; for(auto i : hen[v]) { pair cur = dfs(i, v); sum += (cur.first + cur.second); cnt += cur.second; sum %= mod; } dp[v] = sum; return {sum, cnt}; } int main() { cin >> n; hen.resize(n), dp.resize(n); vector fin(n); for(ll i = 0; i < n - 1; i++) { ll a, b; cin >> a >> b; a--, b--; hen[a].emplace_back(b); fin[b]++; } root = find(fin.begin(), fin.end(), 0) - fin.begin(); dfs(root, -1); cout << accumulate(dp.begin(), dp.end(),0LL, [](ll a, ll b){return (a + b) % mod;}) << endl; }