#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;
const int mod=1e9+7;

const int N=1000;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline void gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline void gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc());
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;

VI e[N];
int dep[N],n,G[N];
void dfs(int k,int fa) {
	for (int t:e[k])
		if (t!=fa)
			G[t]=k,dep[t]=dep[k]+1,dfs(t,k);
}
VI q[N];
LL solve(int k) {
	dep[k]=0;
	dfs(k,0);
	for (int i=1;i<=n;i++) q[dep[i]].pb(i);
	LL ans=1;
	for (int d=0;d<n;d++) {
		int mx=0;
		for (int x:q[d]) {
			int s=0;
			for (int t:e[x])
				if (dep[t]==d+1)
					s++;
			upmax(mx,s);
		}
		if (!mx) break;
		ans*=mx;
	}
	return ans;
}
LL solve(int a,int b) {
	dep[a]=dep[b]=0;
	dfs(a,b);dfs(b,a);
	for (int i=0;i<n;i++) q[i].clear();
	for (int i=1;i<=n;i++) q[dep[i]].pb(i);
	LL ans=1;
	for (int d=0;d<n;d++) {
		int mx=0;
		for (int x:q[d]) {
			int s=0;
			for (int t:e[x])
				if (dep[t]==d+1)
					s++;
			upmax(mx,s);
		}
		if (!mx) break;
		ans*=mx;
	}
	return ans<<1;
}

int main()
{
	int i,a,b;
	gi(n);
	for (i=1;i<n;i++)
		gi(a),gi(b),e[a].pb(b),e[b].pb(a);
	
	dfs(1,0);
	for (i=2,a=1;i<=n;i++)
		if (dep[i]>dep[a]) a=i;
	dep[a]=0;
	dfs(a,0);
	for (i=2,b=1;i<=n;i++)
		if (dep[i]>dep[b]) b=i;

	LL ans;
	print(dep[b]/2+1);putc(' ');
	if (dep[b]&1) {
		for (i=dep[b]>>1;i--;b=G[b]);
		ans=solve(G[b],b);
	} else {
		for (i=dep[b]>>1;i--;b=G[b]);
		ans=solve(b);
		for (int t:e[b])
			upmin(ans,solve(t,b));
	}
	print(ans);
	return 0;
}


Measured memory_bytes: 2304