#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int MOD = 1e9 + 7;

long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

int n;
vector<int> graph[500];
long long ans = 5e18;

int dist[500][500];
int go[500][500];

void dfs(int v, int p, int rt, int d)
{
    dist[rt][v] = d;
    go[v][rt] = p;
    for (auto u : graph[v]) if (u != p) dfs(u, v, rt, d + 1);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int v, u;
        cin >> v >> u, v--, u--;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    for (int i = 0; i < n; i++) dfs(i, -1, i, 0);
    int r = 0, v = -1, u = -1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (dist[i][j] > r) r = dist[i][j], v = i, u = j;
    r++;
    if (r % 2 == 0)
    {
        int D = r / 2;
        cout << D << " ";
        vector<int> q;
        while (u != v)
        {
            q.push_back(u);
            u = go[u][v];
        }
        q.push_back(u);
        int c1 = q[q.size() / 2];
        int c2 = q[q.size() / 2 - 1];
        vector<long long> md(D);
        for (int i = 0; i < n; i++)
        {
            int d = min(dist[c1][i], dist[c2][i]);
            int deg = graph[i].size() - 1;
            md[d] = max(md[d], deg);
        }
        long long res = 2;
        for (int i = 0; i < D; i++) res *= max(md[i], 1LL);
        cout << res;
    }
    else
    {
        int D = (r + 1) / 2;
        cout << D << " ";
        vector<int> q;
        while (u != v)
        {
            q.push_back(u);
            u = go[u][v];
        }
        q.push_back(u);
        int c1 = q[q.size() / 2];
        for (auto c2 : graph[c1])
        {
            vector<long long> md(D);
            for (int i = 0; i < n; i++)
            {
                int d = min(dist[c1][i], dist[c2][i]);
                int deg = graph[i].size() - 1;
                md[d] = max(md[d], deg);
            }
            long long res = 2;
            for (int i = 0; i < D; i++) res *= max(md[i], 1LL);
            ans = min(ans, res);
        }
        vector<long long> md(D);
        for (int i = 0; i < n; i++)
        {
            int d = dist[c1][i];
            int deg = graph[i].size() - (d != 0);
            md[d] = max(md[d], deg);
        }
        long long res = 1;
        for (int i = 0; i < D; i++) res *= max(md[i], 1LL);
        ans = min(ans, res);
        cout << ans;
    }
}


Measured memory_bytes: 640