#include<bits/stdc++.h>
#define ll long long
#define N 5010
#define mod 1000000007
using namespace std;
ll jc[N],inv[N];
ll K(ll x,int y=mod-2){
	ll t=1; for (;y;y>>=1,x=x*x%mod) if (y&1) t=t*x%mod; return t;
}
ll C(int x,int y){
	return jc[x]* inv[y]%mod *inv[x-y]%mod;
}
void U(ll &x,int y){
	if ((x+=y)>=mod) x-=mod;
}

int a[N],tot,cnt; ll f[N],g[N];
ll doit(int cc=cnt){
	memset(f,0,sizeof f); f[0]=1; tot=0;
	for (int i=1;i<=cc;++i){
		memset(g,0,sizeof g);
		for (int j=0;j<=a[i];++j)
			for (int k=tot;~k;--k)
				U(g[k+j],f[k]*C(a[i],j)%mod*C(a[i],j)%mod*jc[j]%mod);
		tot+=a[i];
		memcpy(f,g,sizeof g);
	}
	for (int i=tot;~i;--i) f[i]=f[i]*jc[tot-i]%mod;
	for (int i=tot;~i;--i){
		for (int j=i-1;~j;--j)
			U(f[j],mod-f[i]*C(i,j)%mod);
	}
	return f[0];
}

int n,x,y,sz[N]; vector<int>G[N];
void dfs(int x,int fff){
	int mx=0; sz[x]=1;
	for (auto y:G[x]) if (y-fff){
		dfs(y,x); sz[x]+=sz[y];
		mx=max(mx,sz[y]);
	}
	mx=max(mx,n-sz[x]);
	if (mx*2==n) exit(0*printf("%lld",jc[mx]*jc[mx]%mod));
	if (mx*2>n) return;
	for (auto y:G[x]) if (y-fff) a[++cnt]=sz[y];
	if (x-1) a[++cnt]=n-sz[x]; a[++cnt]=1;
	exit(0*printf("%lld",(doit()+doit(cnt-1))%mod));
}

int main(){
	jc[0]=1; for (int i=1;i<N;++i) jc[i]=jc[i-1]*i%mod;
	inv[N-1]=K(jc[N-1]); for (int i=N;i--;) inv[i-1]=inv[i]*i%mod;
	cin>>n;
	for (int i=n;--i;) cin>>x>>y, G[x].push_back(y), G[y].push_back(x);
	dfs(1,0);
}