#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7,N=5005;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  tmp%=mod;
  return tmp;
}
int pow1(int x,int y)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x);
      x=mult(x,x);
      y>>=1;
    }
  return ans;
}
int fact[N],inv[N],dp[2][N],child[N];
vi v[N];
vi centres;
void dfs(int u,int par=-1)
{
  child[u]=1;
  for(int v1:v[u])
    {
      if(v1==par) continue;
      dfs(v1,u);
      child[u]+=child[v1];
    }
}
int n;
void fun()
{
  int u=1,p=0;
  while(true)
    {
      bool ok=true;
      for(int v1:v[u])
	{
	  if(v1==p) continue;
	  if(child[v1]>n/2)
	    {
	      ok=false;
	      p=u; u=v1;
	      break;
	    }
	}
      if(ok) break;
    }
  centres.pb(u);
  if(n&1) return;
  for(int v1:v[u])
    {
      if(v1==p) continue;
      if(child[v1]==n/2)
	{
	  centres.pb(v1);
	  break;
	}
    }
}
int ncr(int x,int y)
{
  if(x<y || y<0) return 0;
  return mult(fact[x],mult(inv[y],inv[x-y]));
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  fact[0]=inv[0]=1;
  rep(i,1,N) fact[i]=mult(fact[i-1],i);
  inv[N-1]=pow1(fact[N-1],mod-2);
  repv(i,1,N-1)
    {
      inv[i]=mult(inv[i+1],i+1);
      assert(mult(fact[i],inv[i])==1);
    }
  int x,y;
  cin>>n;
  rep(i,1,n)
    {
      cin>>x>>y;
      v[x].pb(y); v[y].pb(x);
    }
  dfs(1);
  fun();
  if(sz(centres)==2)
    {
      cout<<mult(fact[n/2],fact[n/2])<<endl;
      return 0;
    }
  int root=centres[0];
  dfs(root);
  dp[0][0]=1;
  int bit=1;
  for(int v1:v[root])
    {
      rep(i,0,n-child[v1]+1)
	{
	  rep(j,0,child[v1]+1)
	    {
	      dp[bit][i+j]=add(dp[bit][i+j],mult(mult(dp[1-bit][i],ncr(child[v1],j)),mult(fact[j],ncr(child[v1],j))));
	    }
	}
      bit=1-bit;
      rep(i,0,n+1) dp[bit][i]=0;
    }
  int ans=0;
  rep(i,0,n)
    {
      if(i&1)
	ans=add(ans,-mult(dp[1-bit][i],fact[n-i]));
      else
	ans=add(ans,mult(dp[1-bit][i],fact[n-i]));
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 896