#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
const ll mod = 1000000007;
ll N;
vector<ll> paths[5010];
ll sz[5010];
vector<ll> center;
vector<ll> inv, FactorialInv, Factorial;
ll beki(ll a, ll b){
    ll ret = 1 % mod;
    a %= mod;
    while(b) {
        if(b & 1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}
void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    inv.resize(MAX + 1);
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

void dfs(int now, int from) {
    sz[now] = 1;
    for(auto to : paths[now]) {
        if(to == from) continue;
        dfs(to, now);
        sz[now] += sz[to];
    }
    bool iscenter = true;
    for(auto to : paths[now]) {
        if(to == from) {
            int p = N - sz[now];
            if(2 * p > N) iscenter = false;
        } else {
            if(2 * sz[to] > N) iscenter = false;
        }
    }
    if(iscenter) center.push_back(now);
}

vector<ll> v;
ll Prev[5005], Next[5005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination(10000);
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    dfs(0, -1);
    //for(auto v : center) cerr << v << endl;
    if(center.size() == 2) {
        v.push_back(N / 2);
        v.push_back(N / 2);
    } else {
        dfs(center[0], -1);
        for(auto tmp : paths[center[0]]) {
            v.push_back(sz[tmp]);
        }
    }
    /*
    for(auto tmp : v) cerr << tmp << " ";
    cerr << endl;
    */
    Prev[0] = 1;
    for(auto tmp : v) {
        for(int i = 0; i <= N; i++) Next[i] = 0;
        for(ll num = 0; num <= tmp; num++) {
            ll factor = combination(tmp, num);
            factor *= Factorial[tmp];
            factor %= mod;
            factor *= FactorialInv[tmp - num];
            factor %= mod;
            for(int j = 0; j + num <= N; j++) {
                Next[j+num] += Prev[j] * factor;
                Next[j+num] %= mod;
            }
        }
        swap(Prev, Next);
    }
    ll ans = 0;
    for(int i = 0; i <= N; i++) {
        if(i & 1) ans += (mod - Prev[i]) * Factorial[N-i];
        else ans += Prev[i] * Factorial[N-i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280