#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
vector<int>pat[1000];
vector<int>ko[1000];
bool flag[1000];
int dist[1000];
int par[1000];
bool cent[1000];
void dfs(int node, int d)
{
	flag[node] = true;
	dist[node] = d;
	for (int i = 0; i < pat[node].size(); i++)
	{
		if (!flag[pat[node][i]])
		{
			dfs(pat[node][i], d + 1);
			par[pat[node][i]] = node;
			ko[node].push_back(pat[node][i]);
		}
	}
}
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
map<pi3, ll>ma;
ll calc(int node, int u, int d)
{
	if (u < 0 || d < 0)return 0;
	pi3 zz = make_pair(node, make_pair(u, d));
	if (ma.count(zz))return ma[zz];
	ll ans = 1;
	for (int i = 0; i < ko[node].size(); i++)
	{
		if (!cent[ko[node][i]])
		{
			ans *= calc(ko[node][i], u - 1, d) + calc(ko[node][i], u, d - 1);
			ans %= mod;
		}
	}
	return ma[zz] = ans;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb);
		pat[zb].push_back(za);
	}
	dfs(0, 0);
	int maxi = 0, rr = -1;
	for (int i = 0; i < num; i++)if (maxi < dist[i])maxi = dist[i], rr = i;
	fill(flag, flag + num, false);
	dfs(rr, 0);
	maxi = 0;
	for (int i = 0; i < num; i++)if (maxi < dist[i])maxi = dist[i], rr = i;
	if (maxi % 2 == 0)
	{
		for (int i = 0; i < maxi / 2; i++)rr = par[rr];
		cent[rr] = true;
		fill(flag, flag + num, false);
		for (int i = 0; i < num; i++)ko[i].clear();
		dfs(rr, 0);
		ll r = 0;
		for (int i = 0; i <= maxi / 2; i++)r += calc(rr, i, maxi / 2 - i);
		printf("%lld\n", r%mod);
	}
	else
	{
		for (int i = 0; i < maxi / 2; i++)rr = par[rr];
		cent[rr] = true;
		cent[par[rr]] = true;
		fill(flag, flag + num, false);
		for (int i = 0; i < num; i++)ko[i].clear();
		dfs(par[rr], 0);
		ll r = 0;
		int l = (maxi + 1) / 2;
		//printf("%d %d %d\n", rr + 1, par[rr] + 1, l);
		for (int i = 0; i <= (maxi + 1) / 2; i++)
		{
			ll s = (mod + mod + calc(rr, i, l - i) - calc(rr, i - 1, l - i) - calc(rr, i, l - i - 1)) % mod;
			ll t = calc(par[rr], i, l - i - 1);
			ll u = calc(rr, i, l - i - 1);
			ll v = calc(par[rr], i + 1, l - i - 1);
			//printf("%lld %lld %lld %lld\n", s, t, u, v);
			r += s*t + u*v;
			r %= mod;
		}
		printf("%lld\n", r * 2 % mod);
	}
}