#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second

const ll MOD=1000000007;
ll modpow(ll x,ll k,ll mod=MOD){
	if(k==0)return 1;
	ll ret=modpow(x,k/2,mod);
	ret*=ret; ret%=mod;
	if(k%2==1){
		ret*=x; ret%=mod;
	}
	return ret;
}

template <const int p=998244353,int t=20>
struct CONV{
	ll a[(1<<t)+2];
	ll b[(1<<t)+2];
	ll c[(1<<t)+2];
	ll r[(1<<t)+2];
	CONV(){
		for(int i=0;i<(1<<t)+2;i++){
			a[i]=b[i]=c[i]=0;
		}
		int tt=0;
		int x=p-1;
		while(x%2==0){
			tt++;
			x/=2;
		}
		r[1]=1;
		while(1){
			r[1]++;
			if(modpow(r[1],1<<(tt-1),p)==p-1)break;
		}
		for(int i=0;i<tt-t;i++){
			r[1]*=r[1];
			r[1]%=p;
		}
		r[0]=1;
		for(int i=2;i<(1<<t)+2;i++){
			r[i]=r[i-1]*r[1];
			r[i]%=p;
		}
	}
	void init(int tt){
		for(int i=0;i<(1<<tt)+2;i++){
			a[i]=b[i]=c[i]=0;
		}
	}
	ll coef_a[(1<<t)+2];
	ll coef_b[(1<<t)+2];
	void DFT(ll* f,ll* g,int tt){
		g[0]=0;
		for(int i=0;i<tt;i++){
			for(int j=0;j<(1<<i);j++){
				g[j+(1<<i)]=g[j]+(1<<(tt-1-i));
			}
		}
		for(int i=0;i<(1<<tt);i++){
			g[i]=f[g[i]];
		}
		constexpr ll pp2=4L*p;
		for(int i=0;i<tt;i++){
			if(1){
				for(int j=0;j<(1<<tt);j++){
					if((j>>i)&1)continue;
					if(g[j+(1<<i)]==0){
						g[j+(1<<i)]=g[j];
						continue;
					}
					ll y=g[j+(1<<i)]*r[(j&((1<<i)-1))<<(t-i-1)]%p;
					g[j+(1<<i)]=g[j]+p-y;
					g[j]+=y;
					/*g[j+(1<<i)]*=r[(j&((1<<i)-1))<<(t-i-1)];
					g[j+(1<<i)]%=p;
					g[j]+=g[j+(1<<i)];
					if(g[j]>=p)g[j]-=p;
					g[j+(1<<i)]=g[j]+2*(p-g[j+(1<<i)]);
					while(g[j+(1<<i)]>=p)g[j+(1<<i)]-=p;*/
				}
			}
			else {
				for(int j=0;j<(1<<tt);j++){
					if((j>>i)&1)continue;
					if(g[j+(1<<i)]==0){
						g[j+(1<<i)]=g[j];
						continue;
					}
					ll y=g[j+(1<<i)]*r[(j&((1<<i)-1))<<(t-i-1)]%p;
					g[j+(1<<i)]=g[j]+p-y;
					if(g[j+(1<<i)]>=pp2)g[j+(1<<i)]-=pp2;
					g[j]+=y;
					if(g[j]>=pp2)g[j]-=pp2;
				}
			}
		}
	}
	void inv_DFT(ll* f,ll* g,int tt){
		g[0]=0;
		for(int i=0;i<tt;i++){
			for(int j=0;j<(1<<i);j++){
				g[j+(1<<i)]=g[j]+(1<<(tt-1-i));
			}
		}
		for(int i=0;i<(1<<tt);i++){
			g[i]=f[g[i]];
		}
		constexpr ll pp2=8L*p;
		for(int i=0;i<tt;i++){
			if(1){
				for(int j=0;j<(1<<tt);j++){
					if((j>>i)&1)continue;
					if(g[j+(1<<i)]==0){
						g[j+(1<<i)]=g[j];
						continue;
					}
					ll y=g[j+(1<<i)]*r[(1<<t)-((j&((1<<i)-1))<<(t-i-1))]%p;
					g[j+(1<<i)]=g[j]+p-y;
					g[j]+=y;
					/*g[j+(1<<i)]*=r[(j&((1<<i)-1))<<(t-i-1)];
					g[j+(1<<i)]%=p;
					g[j]+=g[j+(1<<i)];
					if(g[j]>=p)g[j]-=p;
					g[j+(1<<i)]=g[j]+2*(p-g[j+(1<<i)]);
					while(g[j+(1<<i)]>=p)g[j+(1<<i)]-=p;*/
				}
			}
			else {
				for(int j=0;j<(1<<tt);j++){
					if((j>>i)&1)continue;
					if(g[j+(1<<i)]==0){
						g[j+(1<<i)]=g[j];
						continue;
					}
					ll y=g[j+(1<<i)]*r[(1<<t)-((j&((1<<i)-1))<<(t-i-1))]%p;
					g[j+(1<<i)]=g[j]+p-y;
					if(g[j+(1<<i)]>=pp2)g[j+(1<<i)]-=pp2;
					g[j]+=y;
					if(g[j]>=pp2)g[j]-=pp2;
				}
			}
		}
	}
	void run(int tt){
		DFT(a,coef_a,tt);
		DFT(b,coef_b,tt);
		for(int i=0;i<(1<<tt);i++){
			coef_a[i]%=p;
			coef_b[i]%=p;
			coef_a[i]*=coef_b[i];
			coef_a[i]%=p;
		}
		inv_DFT(coef_a,coef_b,tt);
		ll inv=modpow(1<<tt,p-2,p);
		for(int i=0;i<(1<<tt);i++){
			coef_b[i]%=p;
			c[i]=coef_b[i]*inv;
			c[i]%=p;
		}
	}
};

inline ll CRT(ll m2,ll a1,ll a2,ll s1){
	//x=a1(mod m1), x=a2(mod m2), s1*m1=1(mod m2)
	//x=ret*m1+a1 (mod m1*m2)
	return (a2-a1%m2+m2)*s1%m2;
}

ll s1=modpow(1045430273,1051721729-2,1051721729);
ll s2=modpow(1045430273*1051721729LL%1053818881,1053818881-2,1053818881);
ll pp=1045430273*1051721729LL%1000000007;

template<int p=1000000007,int t=20>
struct CONV_arb{
	ll a[(1<<t)+2];
	ll b[(1<<t)+2];
	ll c[(1<<t)+2];
	const ll p1=1045430273;
	const ll p2=1051721729;
	const ll p3=1053818881;
	void init(int tt){
		for(int i=0;i<(1<<tt)+2;i++){
			a[i]=b[i]=0;
		}
	}
	void run(int tt){
		static CONV<1045430273,14> conv1;
		static CONV<1051721729,14> conv2;
		static CONV<1053818881,14> conv3;
		//conv1.init(tt);
		//conv2.init(tt);
		//conv3.init(tt);
		for(int i=0;i<(1<<tt);i++){
			conv1.a[i]=conv2.a[i]=conv3.a[i]=a[i];
			conv1.b[i]=conv2.b[i]=conv3.b[i]=b[i];
		}
		conv1.run(tt);
		conv2.run(tt);
		conv3.run(tt);
		for(int i=0;i<(1<<tt);i++){
			ll x=conv1.c[i]+CRT(p2,conv1.c[i],conv2.c[i],s1)*p1;
			ll y=CRT(p3,x,conv3.c[i],s2);
			y*=pp;
			c[i]=x+y;
			c[i]%=p;
		}
	}
};

ll fac[5002];
ll fac_inv[5002];
ll inv[5002];
void init(){
	fac[0]=fac_inv[0]=1;
	for(int i=1;i<5002;i++){
		fac[i]=fac[i-1]*i;
		fac[i]%=MOD;
		fac_inv[i]=modpow(fac[i],MOD-2);
	}
	for(int i=0;i<5002;i++){
		inv[i]=modpow(i,MOD-2);
	}
}

int n;
vector<int> G[5002];
int cnt[5002];
ll dp[5002][5002];
ll memo[5002];

CONV_arb<1000000007,14> conv;

void dfs(int v,int p){
	cnt[v]=1;
	for(int i=0;i<5002;i++){
		dp[v][i]=0;
	}
	dp[v][1]=1;
	for(int u: G[v]){
		if(u==p)continue;
		dfs(u,v);
		for(int i=0;i<=cnt[v]+cnt[u];i++){
			memo[i]=0;
		}
		if(min(cnt[u],cnt[v])<=40){
			for(int i=0;i<=min(cnt[v],n-cnt[v]);i++){
				if(dp[v][i]==0)continue;
				for(int j=1;j<=min(cnt[u],n-cnt[u]);j++){
					if(dp[u][j]==0)continue;
					ll x=dp[v][i]*dp[u][j];
					x%=MOD;
					for(int k=0;k<=min(i,j);k++){
						memo[i+j-2*k]+=x;
						if(memo[i+j-2*k]>=MOD)memo[i+j-2*k]-=MOD;
						x*=(i-k)*(j-k);
						x%=MOD;
						x*=inv[k+1];
						x%=MOD;
					}
				}
			}
		}
		else {
			int cc=min(cnt[u]+cnt[v],n-cnt[u]-cnt[v]);
			for(int k=0;k<=min(cnt[v],cnt[u]);k++){
				int tt=0;
				while((1<<tt)<=min(2*cc,min(cnt[v],n-cnt[v])+min(cnt[u],n-cnt[u])-2*k))tt++;
				if(tt>0)tt--;
				conv.init(tt);
				for(int i=k;i<=min(cc+k,min(cnt[v],n-cnt[v]));i++){
					if(dp[v][i]==0)continue;
					conv.a[(i-k)/2]=dp[v][i];
					conv.a[(i-k)/2]*=fac[i]; conv.a[(i-k)/2]%=MOD;
					conv.a[(i-k)/2]*=fac_inv[i-k]; conv.a[(i-k)/2]%=MOD;
				}
				for(int j=max(1,k);j<=min(cc+k,min(cnt[u],n-cnt[u]));j++){
					if(dp[u][j]==0)continue;
					conv.b[(j-k)/2]=dp[u][j];
					conv.b[(j-k)/2]*=fac[j]; conv.b[(j-k)/2]%=MOD;
					conv.b[(j-k)/2]*=fac_inv[j-k]; conv.b[(j-k)/2]%=MOD;
					conv.b[(j-k)/2]*=fac_inv[k]; conv.b[(j-k)/2]%=MOD;
				}
				conv.run(tt);
				int x=((cnt[v]-k)&1)+((cnt[u]-k)&1);
				for(int i=0;i<(1<<tt);i++){
					memo[2*i+x]+=conv.c[i];
					if(memo[2*i+x]>=MOD)memo[2*i+x]-=MOD;
				}
			}
		}
		for(int i=0;i<=cnt[v]+cnt[u];i++){
			dp[v][i]=memo[i];
		}
		cnt[v]+=cnt[u];
	}
}

ll CNT[5002];
ll dfs2(int v,int p){
	CNT[v]=1;
	ll ret=0;
	for(int u: G[v]){
		if(u==p)continue;
		ret+=dfs2(u,v);
		ll x=CNT[v];
		ll y=CNT[u];
		ll k=min(CNT[u],CNT[v]);
		ret+=k*x*y;
		ret-=k*(k-1)*(x+y)/2;
		ret+=k*(k-1)*(2*k-1)/6;
		CNT[v]+=CNT[u];
	}
}

int main(){
	init();
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	//srand((unsigned)time(NULL));
	int root=1;
	ll MIN=1000000000000;
	for(int i=1;i<=n;i++){
		ll x=dfs2(i,0);
		if(x<MIN){
			MIN=x;
			root=i;
		}
	}
	dfs(root,0);
	cout<<dp[root][0]<<endl;
}



Measured memory_bytes: 198528