#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


vector<int>G[1010];

void search(int n, int pre, int res, int &mx, int &s) {
	if (res > mx) {
		mx = res;
		s = n;
	}
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		search(nxt, n, res + 1, mx, s);
	}
}
int ds[2001], dt[2001];
int deg[1010];
void calc_dist(int n, int pre, int res, int *d) {
	d[n] = res;
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		calc_dist(nxt, n, res + 1, d);
	}
}
ll ans = 1;
int N;
bool vis[2020];
int bfs(int m) {
	queue<int>que;
	//que.push(m);
	REP(i, 2 * N)vis[i] = false;
	vis[m] = true;
	int ans = 1;
	ans *= (deg[m]);
	for (auto nxt : G[m]) {
		vis[nxt] = true;
		que.push(nxt);
	}
	while (true) {
		int mx = 1;
		vector<int>nx;
		while (!que.empty()) {
			int cur = que.front(); que.pop();
			mx = max(mx, deg[cur] - 1);
			for (auto nxt : G[cur]) {
				if (!vis[nxt]) {
					vis[nxt] = true;
					nx.push_back(nxt);
				}
			}
		}
		ans *= mx;
		if (nx.empty())break;
		for (auto n : nx)que.push(n);
	}
	return ans;
}
int bfs2(int m, int n) {
	REP(i, 2 * N)vis[i] = false;
	int ans = 2;
	queue<int>que;

	vis[m] = true;
	vis[n] = true;
	for (auto nxt : G[m]) {
		if (vis[nxt])continue;
		vis[nxt] = true;
		que.push(nxt);
	}
	for (auto nxt : G[n]) {
		if (vis[nxt])continue;
		vis[nxt] = true;
		que.push(nxt);
	}
	while (true) {
		int mx = 1;
		vector<int>nx;
		while (!que.empty()) {
			int cur = que.front(); que.pop();
			mx = max(mx, deg[cur] - 1);
			for (auto nxt : G[cur]) {
				if (!vis[nxt]) {
					vis[nxt] = true;
					nx.push_back(nxt);
				}
			}
		}
		ans *= mx;
		if (nx.empty())break;
		for (auto n : nx)que.push(n);
	}
	return ans;
}
void solve() {
cin >> N;
	REP(i, N-1) {
		int u, v; cin >> u>> v;
		u--, v--;
		G[u].push_back(N + i);
		deg[u]++;
		deg[v]++;
		deg[N + i] += 2;
		G[N + i].push_back(u);
		G[N + i].push_back(v);
		G[v].push_back(N + i);
	}
	int mx = 0, s = 0, t = 0;

	search(0, 0, 0, mx, s);
	mx = 0;
	search(s, s, 0, mx, t);
	//print(mx);
	calc_dist(s, s, 0, ds);
	calc_dist(t, t, 0, dt);
	int mid = 0;
	REP(i, 2 * N) {
		if (ds[i] == dt[i] && ds[i] + dt[i] == mx) {
			mid = i; break;
		}
	}
	//DEBUG(mid);
	pe((mx/2+2)/2);
	ans = 1e18;
	ans = min(ans, bfs(mid));
	if ((mx / 2) %2==0) {
		for (auto nxt : G[mid]) {
			ans = min(ans, bfs(nxt));
		}
	}
	print(ans);
}




signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 384