#include<cstdio>
#include<cstring>
#include<iostream>
#define M 508
using namespace std;
int T=,m,n,head[M],K,next[*M],u[*M],cnt,f[M],c[M],fa[M],dfn[M],low[M],time1,ans,bi[M],sum[M];
long long ans1=;
void jia(int a1,int a2)
{
cnt++;
next[cnt]=head[a1];
head[a1]=cnt;
u[cnt]=a2;
}
void tarjin(int a1,int deep)
{
time1++;
dfn[a1]=low[a1]=time1;
c[a1]=-;
int tot=;
for(int i=head[a1];i;i=next[i])
if(u[i]!=fa[a1])
{
fa[u[i]]=a1;
if(!c[u[i]])
{
tarjin(u[i],deep+);
low[a1]=min(low[a1],low[u[i]]);
tot++;
if(deep==&&tot>)
f[a1]=;
if(deep>&&low[u[i]]>=dfn[a1])
f[a1]=;
}
else if(c[u[i]]==-&&u[i]!=fa[a1])
low[a1]=min(low[a1],dfn[u[i]]);
}
c[a1]=;
}
void dfs(int a1)
{
c[a1]=;
if(!bi[a1])
bi[a1]=time1;
else
bi[a1]=-;
for(int i=head[a1];i;i=next[i])
if(!c[u[i]]&&!f[u[i]])
dfs(u[i]);
return;
}
int main()
{
for(;scanf("%d",&m),m;T++){
ans=cnt=n=;
ans1=;
memset(head,,sizeof(head));
memset(bi,,sizeof(bi));
memset(f,,sizeof(f));
memset(sum,,sizeof(sum));
for(int i=;i<=m;i++)
{
int a1,a2;
scanf("%d%d",&a1,&a2);
n=max(n,a1);
n=max(n,a2);
jia(a1,a2);
jia(a2,a1);
}
time1=;
for(int i=;i<=n;i++)
{
f[i]=;
c[i]=;
fa[i]=;
}
tarjin(,);
time1=;
for(int i=;i<=n;i++)
if(f[i])
{
memset(c,,sizeof(c));
for(int j=head[i];j;j=next[j])
if(!c[u[j]]&&!f[u[j]])
{
time1++;
dfs(u[j]);
}
}
for(int i=;i<=n;i++)
if(bi[i]!=-)
sum[bi[i]]++;
for(int i=;i<=time1;i++)
if(sum[i])
{
ans++;
ans1*=sum[i];
}
printf("Case %d: ",T);
if(ans)
printf("%d %lld\n",ans,ans1);
else
printf("2 %d\n",n*(n-)/);}
return ;
}
先用tarjin找割点 割点条件u1是树根,且有大于1棵子树,u1不是树根,low[u[i]]>dfn[u1],把和一个割点相连的联通块建出口。