#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) (cerr<<__LINE__<<": ",_dbg(#__VA_ARGS__, __VA_ARGS__))
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

template<int mod=1000000007>
class ModInt {
  int x;
public:
  ModInt() : x(0) {}
  ModInt(const ModInt &y): x(y.x) {}
  ModInt(int64_t y){ x = y % mod; if(x < 0) x += mod; }
  ModInt &operator += (const ModInt &p){ x += p.x; if(x >= mod) x -= mod; return *this; }
  ModInt &operator -= (const ModInt &p){ x -= p.x; if(x < 0) x += mod; return *this; }
  ModInt &operator *= (const ModInt &p){ x = (int) (1LL * x * p.x % mod); return *this; }
  ModInt &operator /= (const ModInt &p){ *this *= p.inverse(); return *this; }
  ModInt operator -() const { return ModInt(-x); }
  ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator == (const ModInt &p) const { return x == p.x; }
  bool operator != (const ModInt &p) const { return x != p.x; }
  ModInt operator = (const int64_t y) { return *this = ModInt(y); }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0){
      t = a/b; a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t y) const {
    if(x==0) return ModInt(0);
    int64_t r = 1, t = x;
    while(y > 0){
      if(y&1) r = r*t%mod;
      t = t*t%mod; y >>= 1;
    }
    return ModInt(r);
  }
  friend ostream &operator << (ostream &os, const ModInt<mod> &p) { return os<<p.x; }
  friend istream &operator >> (istream &is, ModInt<mod> &a) { int64_t x; is>>x; a = ModInt<mod>(x); return is; }
};
using Int = ModInt<>;

vector<int> g[5003];

int dfs(int v, int from){
  int ret = 1;
  for(auto to : g[v]) if(to != from) ret += dfs(to, v);
  return ret;
}

vector<int> calc_ch(int root){
  vector<int> ret;
  for(auto to : g[root]) ret.pb(dfs(to, root));
  return ret;
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  vector<pair<int,int>> v;
  rep(i,n){
    auto rv = calc_ch(i);
    v.pb(mp(*max_element(all(rv)), i));
  }
  sort(all(v));

  vector<Int> fact(n+1);
  vector<Int> inv(n+1);
  fact[0] = 1;
  rep(i,n) fact[i+1] = fact[i]*(i+1);
  rep(i,1,n+1) inv[i] = Int(i).inverse();

  if(v[0].fi == v[1].fi){
    assert(v[0].fi == n/2 && v[1].fi == n/2);
    cout << fact[n/2] * fact[n/2] << endl;
    return 0;
  }
  else {
    auto a = calc_ch(v[0].se);
    int m = a.size();
    sort(all(a));
    vector<Int> sel(1,1);
    rep(i,m){
      vector<Int> nxt(sel.size() + a[i], 0);
      rep(j,sel.size()){
        Int comb = 1;
        rep(k,a[i]+1){
          nxt[j+k] += sel[j] * comb * comb * fact[k];
          comb = comb * (a[i]-k) * inv[k+1];
        }
      }
      swap(nxt, sel);
    }
    assert(sel.size() == n);

    Int ans = 0;
    long sgn = 1;
    rep(k,n){
      ans += sel[k] * fact[n-k] * sgn;
      sgn *= -1;
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 896