#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long ll; typedef pair P; const ll MOD=1e9+7; ll dp[1010][2020]; vector g[1010]; int c; int p2[1010]; int par[1010]; void dfs(int x, int p){ par[x]=p; for(auto y:g[x]){ if(y==p) continue; dfs(y, x); } } ll solve(int x, int v){ if(dp[x][v]!=-1) return dp[x][v]; if(v>=c) return dp[x][v]=0; ll ret=1; for(auto y:g[x]){ if(y==par[x]) continue; ll s=0; if(v-1>=0) s+=solve(y, v-1); if(v+1>n>>c0; for(int i=0; i>a>>b; a--; b--; g[a].push_back(b); g[b].push_back(a); } dfs(0, -1); ll ans=0; p2[0]=1; for(int i=1; i<=n; i++) p2[i]=p2[i-1]*2%MOD; for(int r=0; r<3; r++){ c=(c0-r-1)/3+1; for(int j=0; j=min(c, n); i++){ (ans+=dp[0][i])%=MOD; } if(n-1