#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

vector<int> tpsort(vector<vector<int>>& G) {
    int V = G.size();
    vector<int> sorted_vertices;
    queue<int> que;
    vector<int> indegree(V);
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < G[i].size(); j++) {
            indegree[G[i][j]]++;
        }
    }
    for (int i = 0; i < V; i++) {
        if (indegree[i] == 0) {
            que.push(i);
        }
    }
    while (que.empty() == false) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i];
            indegree[u] -= 1;
            if (indegree[u] == 0) que.push(u);
        }
        sorted_vertices.push_back(v);
    }
    return sorted_vertices;
}

struct Point
{
    double x;
    double y;
};

struct LineSegment
{
    Point start;
    Point end;
};

double tenkyori(const LineSegment& line, const Point& point)
{
    double x0 = point.x, y0 = point.y;
    double x1 = line.start.x, y1 = line.start.y;
    double x2 = line.end.x, y2 = line.end.y;

    double a = x2 - x1;
    double b = y2 - y1;
    double a2 = a * a;
    double b2 = b * b;
    double r2 = a2 + b2;
    double tt = -(a * (x1 - x0) + b * (y1 - y0));

    if (tt < 0)
        return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
    else if (tt > r2)
        return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0));

    double f1 = a * (y1 - y0) - b * (x1 - x0);
    return sqrt((f1 * f1) / r2);
}

template <typename X>
struct SegTree {
    using FX = function<X(X, X)>; // X•X -> X となる関数の型
    int n;
    FX fx;
    const X ex;
    vector<X> dat;
    SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }

    void set(int i, X x) { dat[i + n - 1] = x; }
    void build() {
        for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
    }

    void update(int i, X x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return ex;
        }
        else if (a <= l && r <= b) {
            return dat[k];
        }
        else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
};

template <typename X, typename M>
struct SegTreeLazy {
    using FX = function<X(X, X)>;
    using FA = function<X(X, M)>;
    using FM = function<M(M, M)>;
    int n;
    FX fx;
    FA fa;
    FM fm;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    SegTreeLazy(int n_, FX fx_, FA fa_, FM fm_, X ex_, M em_)
        : n(), fx(fx_), fa(fa_), fm(fm_), ex(ex_), em(em_), dat(n_ * 4, ex), lazy(n_ * 4, em) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
    }

    void set(int i, X x) { dat[i + n - 1] = x; }
    void build() {
        for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
    }

    void eval(int k) {
        if (lazy[k] == em) return; 
        if (k < n - 1) {            
            lazy[k * 2 + 1] = fm(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = fm(lazy[k * 2 + 2], lazy[k]);
        }
        
        dat[k] = fa(dat[k], lazy[k]);
        lazy[k] = em;
    }

    void update(int a, int b, M x, int k, int l, int r) {
        eval(k);
        if (a <= l && r <= b) {  
            lazy[k] = fm(lazy[k], x);
            eval(k);
        }
        else if (a < r && l < b) {                     
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  
            dat[k] = fx(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int a, int b, M x) { update(a, b, x, 0, 0, n); }

    X query_sub(int a, int b, int k, int l, int r) {
        eval(k);
        if (r <= a || b <= l) {
            return ex;
        }
        else if (a <= l && r <= b) {
            return dat[k];
        }
        else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
    X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
};

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> z(n);
    for (int i = 0; i < n-1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        z[a].push_back(b);
        z[b].push_back(a);
    }
    queue<ll> q;
    q.push(0);
    vector<int> seen(n,-1);
    seen[0] = 0;
    while (!q.empty()) {
        ll b = q.front();
        for (int i = 0; i < z[b].size(); i++) {
            if (seen[z[b][i]] == -1) {
                q.push(z[b][i]);
                seen[z[b][i]] = seen[b]+1;
            }
        }
        q.pop();
    }
    ll mx = -1;
    ll tgtg = 0;
    for (int i = 0; i < n; i++) {
        if (mx < seen[i]) {
            tgtg = i;
            mx = seen[i];
        }
    }
    q.push(tgtg);
    vector<int> seent(n, -1);
    seent[tgtg] = 0;
    while (!q.empty()) {
        ll b = q.front();
        for (int i = 0; i < z[b].size(); i++) {
            if (seent[z[b][i]] == -1) {
                q.push(z[b][i]);
                seent[z[b][i]] = seent[b] + 1;
            }
        }
        q.pop();
    }
    mx = -1;
    ll k = 0;
    for (int i = 0; i < n; i++) {
        if (mx < seent[i]) {
            k = i;
            mx = seent[i];
        }
    }
    q.push(k);
    vector<int> seenti(n, -1);
    seenti[k] = 0;
    while (!q.empty()) {
        ll b = q.front();
        for (int i = 0; i < z[b].size(); i++) {
            if (seenti[z[b][i]] == -1) {
                q.push(z[b][i]);
                seenti[z[b][i]] = seenti[b] + 1;
            }
        }
        q.pop();
    }
    
    if (mx % 2 == 0) {
        ll r = -1;
        for (int i = 0; i < n; i++) {
            if (seent[i] == mx / 2 && seenti[i] == mx / 2)r = i;
        }
        ll nans = 156257334530;
        cout << mx / 2 + 1 << " ";
        for (int j = 0; j < z[r].size(); j++) {
            ll s = z[r][j];
            q.push(r);
            q.push(s);
            vector<ll> seentik(n, -1);
            seentik[r] = 10000;
            seentik[s] = 0;
            while (!q.empty()) {
                ll b = q.front();
                for (int i = 0; i < z[b].size(); i++) {
                    if (seentik[z[b][i]] == -1) {
                        q.push(z[b][i]);
                        seentik[z[b][i]] = seentik[b] + 1;
                    }
                }
                q.pop();
            }
            vector<ll> mxp(n + 1, 1);
            for (int i = 0; i < n; i++) {
                if (seentik[i] > 1000)continue;
                mxp[seentik[i]] = max((ll)z[i].size() - 1, mxp[seentik[i]]);
            }
            for (int i = 0; i < n; i++) {
                if (seentik[i] < 1000)continue;
                seentik[i] -= 10000;
                mxp[seentik[i]] = max((ll)z[i].size() - 1, mxp[seentik[i]]);
            }
            ll ans = 2;
            for (int i = 0; i < n; i++) {
                ans *= mxp[i];
            }
            nans = min(ans, nans);
        }
        ll s = r;
        q.push(s);
        vector<int> seentik(n, -1);
        seentik[s] = 0;
        while (!q.empty()) {
            ll b = q.front();
            for (int i = 0; i < z[b].size(); i++) {
                if (seentik[z[b][i]] == -1) {
                    q.push(z[b][i]);
                    seentik[z[b][i]] = seentik[b] + 1;
                }
            }
            q.pop();
        }
        vector<ll> mxp(n + 1, 1);
        for (int i = 0; i < n; i++) {
            if (seentik[i] > 1000)continue;
            mxp[seentik[i]] = max((ll)z[i].size() - 1, mxp[seentik[i]]);
        }
        for (int i = 0; i < n; i++) {
            if (seentik[i] < 1000)continue;
            seentik[i] -= 10000;
            mxp[seentik[i]] = max((ll)z[i].size() - 1, mxp[seentik[i]]);
        }
        ll ans = 1;
        for (int i = 0; i < n; i++) {
            if (i == 0)mxp[i]++;
            ans *= mxp[i];
        }
        nans = min(ans, nans);
        cout << nans << endl;
    }
    else {
        ll r = -1;
        ll s = -1;
        for (int i = 0; i < n; i++) {
            if (seent[i] == mx / 2+1 && seenti[i] == mx / 2)r = i;
            if (seent[i] == mx / 2 && seenti[i] == mx / 2+1)s = i;
        }
        cout << mx / 2 + 1 << " ";
        q.push(r);
        q.push(s);
        vector<int> seentik(n, -1);
        seentik[r] = 10000;
        seentik[s] = 0;
        while (!q.empty()) {
            ll b = q.front();
            for (int i = 0; i < z[b].size(); i++) {
                if (seentik[z[b][i]] == -1) {
                    q.push(z[b][i]);
                    seentik[z[b][i]] = seentik[b] + 1;
                }
            }
            q.pop();
        }
        vector<ll> mxp(n + 1,1);
        for (int i = 0; i < n; i++) {
            if (seentik[i] > 1000)continue;
            mxp[seentik[i]] = max((ll)z[i].size() - 1, mxp[seentik[i]]);
        }
        for (int i = 0; i < n; i++) {
            if (seentik[i] < 1000)continue;
            seentik[i] -= 10000;
            mxp[seentik[i]] = max((ll)z[i].size() - 1, mxp[seentik[i]]);
        }
        ll ans = 2;
        for (int i = 0; i < n; i++) {
            ans *= mxp[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3716