#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)	 for(ll i=(ll)(x);i<(ll)(y);++i)
#define For(i,x,y)	 for(ll i=(ll)(x);i<=(ll)(y);++i)
#define FOr(i,x,y)	 for(ll i=(ll)(x);i>=(ll)(y);--i)
#define pi acos(-1)	
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)				((x)<(y)?(y):(x))
#define min(x,y)				((x)<(y)?(x):(y))
#define sqr(x)						((x)*(x))
#define Mul(x,y)				((x)=1LL*(x)*(y)%mod)
#define Add(x,y)				((x)=((x)+(y))%mod)
#define Max(x,y)				((x)=((x)<(y)?(y):(x)))
#define Min(x,y)				((x)=((x)>(y)?(y):(x)))
#define E(x)							 return writeln(x),0
#define LL			(long long)
#define p(x)							 printf("~%lld~\n",LL(x))
#define pp(x,y)				 printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)	 printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)				 freopen(x".in","r",stdin)
#define f_out(x)			 freopen(x".out","w",stdout)
#define open(x)				 f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
			 struct _{_(){freopen("cf.in","r",stdin);}}_;	
#endif 
#define NEG 1
			 static const ll GYN=2333333;
			 char SZB[GYN],*S=SZB,*T=SZB;
			 inline char gc(){		 if (S==T){	 T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';		}		 return *S++;				}
#if NEG
			 inline ll read(){			 ll x=0,g=1; char ch=gc();		 for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;	 for (;isdigit(ch);ch=gc())	 x=x*10-48+ch;		 return x*g;	}
			 inline void write(ll x){			 if (x<0) putchar('-'),x=-x;	 if (x>=10)		 write(x/10);			 putchar(x%10+'0');		}
#else
			 inline ll read(){			 ll x=0; char ch=gc();		 for (;!isdigit(ch);ch=gc());			 for (;isdigit(ch);ch=gc())	 x=x*10-48+ch;		 return x;			}
			 inline void write(ll x){			 if (x>=10)		 write(x/10);			 putchar(x%10+'0');		}
#endif
			 inline char readchar(){ char ch=gc();		 for(;isspace(ch);ch=gc());	 return ch;		}
			 inline ll readstr(char *s){ char ch=gc();		 ll cur=0;	 for(;isspace(ch);ch=gc());					 for(;!isspace(ch);ch=gc())	 s[cur++]=ch;			 s[cur]='\0';			 return cur;	}
	void writeln(ll x){write(x);putchar(' ');}
}using namespace cqz;
 
ll ans[115],fa[115],deep[115],Ans,n;
vector<ll> GGGG[105];
void dfs(ll u){	ans[deep[u]]	= max(ans[deep[u]],(ll)GGGG[u].size()-1);	for(ll i=0;i<GGGG[u].size();++i){		ll v = GGGG[u][i];		if(v == fa[u]) continue;		fa[v]	= u;deep[v]	= deep[u]	+ 1;dfs(v);	}	}
void solve(ll u,ll v){
	memset(ans,0,sizeof ans);
	deep[u]=1;fa[u]=v;dfs(u);
	deep[v]=1;fa[v]=u;dfs(v);
	ll answ = 1;
	For(i,1,n)	if(ans[i]) answ = answ * ans[i];
	Ans = min(Ans,answ*2);
}
signed main(){
	Ans = 1e18;
	n = read();
	rep(i,1,n){		ll a = read(),b = read();		GGGG[b]	. push_back(a);	GGGG[a]	. push_back(b);	}
	deep[1]	= 1;fa[1]=0;dfs(1);	ll u = 1;	For(i,1,n){		if(deep[i]	> deep[u]) u = i;fa[i]	= 0;	}
	deep[u]	= 1;fa[u]=0;dfs(u);	ll v = u;	For(i,1,n)	if(deep[i]	> deep[v]) v = i;	writeln((deep[v]+1)/2);
	if(deep[v]	& 1){
		ll need = deep[v]	/ 2;	while(need--)v = fa[v];
		for(ll i=0;i<GGGG[v].size();++i)	solve(v,GGGG[v][i]);
		memset(ans,0,sizeof ans);	deep[v]=1;fa[v]=0;dfs(v);
		ans[1]	= GGGG[v].size();	ll answ = 1;	for(ll i=1;i<=n;i++)	if(ans[i]) answ = answ * ans[i];
		Ans=min(Ans,answ);
	}
	else{
			ll need = deep[v]	/ 2;		u = v;
			while(need--)	v = u,	u = fa[v];solve(u,v);
	}
	writeln(Ans);
	return 0;
}

Measured memory_bytes: 256