#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;
    V<V<int>> G(n);
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int d[n];
    fill(d, d + n, -1);
    d[0] = 0;
    queue<int> que;
    que.push(0);
    int v;
    while(!que.empty()) {
        v = que.front();
        que.pop();
        for(int u : G[v]) {
            if(d[u] == -1) {
                d[u] = d[v] + 1;
                que.push(u);
            }
        }
    }
    fill(d, d + n, -1);
    d[v] = 0;
    que.push(v);
    int u;
    while(!que.empty()) {
        u = que.front();
        que.pop();
        for(int i : G[u]) {
            if(d[i] == -1) {
                d[i] = d[u] + 1;
                que.push(i);
            }
        }
    }
    int dis = d[u];
    int d2[n];
    fill(d2, d2 + n, -1);
    d2[u] = 0;
    que.push(u);
    while(!que.empty()) {
        int x = que.front();
        que.pop();
        for(int y : G[x]) {
            if(d2[y] == -1) {
                d2[y] = d2[x] + 1;
                que.push(y);
            }
        }
    }
    V<int> vec;
    cout << dis / 2 + 1 << " ";
    rep(i, n) if(abs(d[i] - d2[i]) <= 1 && d[i] + d2[i] == dis)
        vec.push_back(i);
    if(vec.size() == 2) {
        v = vec[0];
        u = vec[1];
        que.push(u);
        que.push(v);
        int mx[n];
        fill(mx, mx + n, 1);
        fill(d, d + n, -1);
        d[v] = d[u] = 0;
        while(!que.empty()) {
            int x = que.front();
            que.pop();
            chmax(mx[d[x]], (int)G[x].size() - 1);
            for(int y : G[x]) {
                if(d[y] == -1) {
                    d[y] = d[x] + 1;
                    que.push(y);
                }
            }
        }
        ll ans = 2;
        rep(i, n) ans *= mx[i];
        cout << ans << endl;
        return 0;
    }
    ll ans = inf;
    v = vec[0];
    int mx[n];
    fill(mx, mx + n, 1);
    mx[0] = G[v].size();
    que.push(v);
    fill(d, d + n, -1);
    d[v] = 0;
    while(!que.empty()) {
        int x = que.front();
        que.pop();
        chmax(mx[d[x]], (int)G[x].size() - 1);
        for(int y : G[x]) {
            if(d[y] == -1) {
                d[y] = d[x] + 1;
                que.push(y);
            }
        }
    }
    ll x = 1;
    rep(i, n) x *= mx[i];
    chmin(ans, x);

    for(int u : G[v]) {
        que.push(u);
        que.push(v);
        fill(mx, mx + n, 1);
        fill(d, d + n, -1);
        d[v] = d[u] = 0;
        while(!que.empty()) {
            int x = que.front();
            que.pop();
            chmax(mx[d[x]], (int)G[x].size() - 1);
            for(int y : G[x]) {
                if(d[y] == -1) {
                    d[y] = d[x] + 1;
                    que.push(y);
                }
            }
        }
        ll x = 2;
        rep(i, n) x *= mx[i];
        chmin(ans, x);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256