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

// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#ifdef USE_COUT
#define dump(...) (cout<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
#else
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
#endif
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///

const int N = 5001;
vector<int> g[N];
int c[N];
int n;
vector<int> centroid;
constexpr ll mod = 1e9 + 7;

/// --- modulo Library {{{ ///
constexpr ll extgcd(ll a, ll b, ll& x, ll& y) {
  if(b==0) {
    x = 1; y = 0;
    return a;
  }
  ll d = extgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}
constexpr ll modpow(ll a, ll b, ll mod = static_cast<int>(1e9 + 7)) {
  a = (a % mod + mod) % mod;
  ll r = 1;
  while(b){
    if(b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
constexpr ll modinv(ll a, ll mod = static_cast<int>(1e9 + 7)) {
  a = (a % mod + mod) % mod;
  ll x = 0, y = 0;
  extgcd(a, mod, x, y);
  return (x % mod + mod) % mod;
}

template<int N, int mod = static_cast<int>(1e9 + 7)> struct Factorial {
  int arr[N+1], inv[N+1];
  long long operator[](int i) const { return arr[i]; }
  constexpr Factorial(): arr(), inv() {
    arr[0] = 1;
    for(int i = 1; i <= N; i++) {
      arr[i] = (long long) i * arr[i - 1] % mod;
    }
    inv[N] = modinv(arr[N], mod);
    for(int i = N-1; i >= 0; i--) {
      inv[i] = (long long) (i + 1) * inv[i + 1] % mod;
    }
  }
  long long C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    return (((ll) arr[n] * inv[r]) % mod * inv[n - r]) % mod;
  }
};
/// }}}--- ///

// constexpr int N = 1e5 + 10;
constexpr Factorial<N, mod> fact;
vector<int> T;

void dfs(int i, int p) {
  c[i] = 1;
  int f = 1;
  for(int j : g[i]) if(j != p) {
    dfs(j, i);
    c[i] += c[j];
    f &= c[j] <= n / 2;
  }
  f &= (n - c[i]) <= n / 2;
  if(f) {
    centroid.emplace_back(i);
    for(int j : g[i]) if(j != p) T.emplace_back(c[j]);
    T.emplace_back(n - c[i]);
  }
}
ll dp[N][N];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  dfs(0, -1);
  ll ans = 0;
  if(centroid.size() == 1) {
    dump("ONE");
    dump(T);
    for(int i = 0; i < T.size(); i++) for(int j = 0; j < n; j++) {
      // 配るDP
      // dp[i][j] => jp[i][j + y]
      for(int y = 0; y <= T[i]; y++) {
        if(j + y >= n) break;
        dp[i + 1][j + y] = (dp[i + 1][j + y] +
            (i == 0 && j == 0 ? 1 : dp[i][j]) * fact.C(T[i], y) % mod * fact.C(T[i], y) % mod *
            fact[y] % mod
            ) % mod;
      }
    }
    for(int x = 0; x <= n - 1; x++) {
      ll res = 1;
      if(x & 1) res *= -1;
      res *= fact[n - x];
      res *= dp[T.size()][x];
      dump(x, res);
      ans += res % mod;
    }
    ans = ((ans % mod + mod) % mod);
  } else {
    dump("TWO");
    ans += fact[n/2] * fact[n/2] % mod;
  }
  cout << ans << endl;
}



Measured memory_bytes: 195968