#include<iostream>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#define MAXN 10500
#define MAXM 550
#define int long long
using namespace std;
int n,m;
struct Edge{
int next,to;
}e[MAXM<<1];
int h[MAXN],cnt;
void add(int u,int v)
{
cnt++;
e[cnt].next = h[u];
e[cnt].to = v;
h[u] = cnt;
}
int tot,dfn[MAXN],low[MAXN];
int cut[MAXN];
void tarjan(int x,int father)
{
tot++;
dfn[x] = low[x] = tot;
int child = 0;
for(int i = h[x];i;i = e[i].next)
{
int y = e[i].to;
if( !dfn[y] )
{
tarjan(y,father);
low[x] = min(low[x],low[y]);
if( low[y] >= dfn[x] && x != father )
cut[x] = 1;
if( x == father )
child++;
}
low[x] = min(low[x],dfn[y]);
}
if( x == father && child >= 2 )
cut[x] = 1;
return ;
}
int color[MAXN];
int cut_num;
int fcut;
int num,ans = 1;
void dfs(int x,int color_num)
{
color[x] = color_num;
fcut++;
for(int i = h[x];i;i = e[i].next)
{
int y = e[i].to;
if( color[y] != color_num && cut[y] )
{
cut_num++;
color[y] = color_num;
}
if( color[y] == 0 )
dfs(y,color_num);
}
}
void clear()
{
memset(e,0,sizeof(e));
memset(h,0,sizeof(h));
memset(dfn,0,sizeof(dfn));
memset(low,0,sizeof(low));
memset(cut,0,sizeof(cut));
memset(color,0,sizeof(color));
tot = cnt = 0;
n = 0;
}
signed main()
{
for(int k = 1; ; k++)
{
scanf("%lld",&m);
if( m == 0 )
break;
clear();
for(int i = 1,s,t;i <= m; i++)
{
scanf("%lld%lld",&s,&t);
add(s,t);
add(t,s);
n = max(n,s);
n = max(n,t);
}
for(int i = 1;i <= n; i++)
if( !dfn[i] )
tarjan(i,i);
for(int i = 1,color_num = 0;i <= n; i++)
{
if( !cut[i] && !color[i] )
{
color_num++;
fcut = cut_num = 0;
dfs(i,color_num);
if( cut_num == 0 )
{
num += 2;
ans *= (fcut-1)*fcut/2;
}
if( cut_num == 1 )
{
num++;
ans *= fcut;
}
}
}
printf("Case %lld: %lld %lld\n",k,num,ans);
}
return 0;
}