// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// contancer library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = unsigned long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class T>
ostream& operator<<(ostream& os, queue<T> q) {
    os << "[";
    while (!q.empty()) {
        os << q.front() << ",";
        q.pop();
    }
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, priority_queue<T> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template <typename T, typename U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <typename T, typename U>
T mpow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * b % MOD;
        n >>= 1;
        b = b * b % MOD;
    }
    return ret;
}

struct Graph {
    Graph(int N) : size(N) { path.resize(N); };
    void span(int u, int v) { path[u].push_back(v); }
    vector<int> adj(int v) { return path[v]; };

    int size;
    vector<vector<int>> path;
};

int N;
Graph tree(0);

vector<int> bfs(vector<int> rs) {
    vector<int> dist(N, INF);
    queue<int> que;

    for (int r : rs) {
        dist[r] = 0;
        que.push(r);
    }

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int sv : tree.adj(v)) {
            if (dist[sv] <= dist[v]) continue;
            dist[sv] = dist[v] + 1;
            que.push(sv);
        }
    }
    return dist;
}

tuple<int, int, int> diameter() {
    auto dist = bfs({0});
    int l = max_element(dist.begin(), dist.end()) - dist.begin();
    dist = bfs({l});
    int r = max_element(dist.begin(), dist.end()) - dist.begin();
    return make_tuple(dist[r], l, r);
}

ll leaf_num(vector<int> center) {
    auto dist = bfs(center);
    vector<ll> hie(N, 0);

    for (int v = 0; v < N; ++v) {
        ll cnt = 0;
        for (int sv : tree.adj(v)) {
            if (dist[sv] > dist[v]) ++cnt;
        }
        hie[dist[v]] = max(hie[dist[v]], cnt);
    }

    ll ret = center.size();
    for (int d = 0; d < N; ++d) {
        if (hie[d] == 0) break;
        ret *= hie[d];
    }
    return ret;
}

int main() {
    cin >> N;

    tree = Graph(N);
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        tree.span(u, v);
        tree.span(v, u);
    }

    int D, l, r;
    tie(D, l, r) = diameter();
    cout << D / 2 + 1 << " ";

    auto ldist = bfs({l}), rdist = bfs({r});
    vector<int> center;
    for (int v = 0; v < N; ++v) {
        if (ldist[v] + rdist[v] == D && abs(ldist[v] - rdist[v]) <= 1) center.push_back(v);
    }

    ll ans = leaf_num(center);
    if (center.size() == 1) {
        int c = center[0];
        for (int sv : tree.adj(c)) {
            ans = min(ans, leaf_num({c, sv}));
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256