#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=500010;
int head[N],low[N],vis[N],dfn[N],sta[N],top;
bool ins[N],insta[N];
int n,m,cnt,num,tot,T,deg,ans1,ans2,cases,root;
struct node
{
int to,next,from;
}e[N];
inline void clear()
{
memset(head,0,sizeof(head));
memset(dfn,0,sizeof(dfn));
memset(low,0,sizeof(low));
memset(ins,0,sizeof(ins));
memset(vis,0,sizeof(vis));
top=cnt=tot=n=ans1=T=0;
ans2=1;
}
inline void add(int a,int b)
{
e[++num].from=a;
e[num].to=b;
e[num].next=head[a];
head[a]=num;
}
void tarjan(int x,int f)
{
dfn[x]=low[x]=++tot;
for(int i=head[x];i!=0;i=e[i].next)
{
int v=e[i].to;
if(!dfn[v])
{
tarjan(v,x);
low[x]=min(low[x],low[v]);
if(low[v]>=dfn[x])
{
if(x==root) deg++;
else ins[x]=1;
}
}
else if(v!=f)
low[x]=min(low[x],dfn[v]);
}
}
void search(int x)
{
vis[x]=T;
if(ins[x]) return;
cnt++;
for(int i=head[x];i;i=e[i].next)
{
int v=e[i].to;
if(ins[v] && vis[v]!=T)
num++,vis[v]=T;
if(!vis[v]) search(v);
}
}
signed main()
{
cin>>m;
while(m)
{
clear();
for (int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
n=max(n,max(u,v));
add(u,v); add(v,u);
}
for (int i=1;i<=n;i++)
{
if (!dfn[i]) tarjan(root=i,0);
if (deg>=2) ins[root]=1;
deg=0;
}
for (int i=1;i<=n;i++)
if (!vis[i]&&!ins[i])
{
T++; cnt=num=0;
search(i);
if (!num) ans1+=2,ans2*=cnt*(cnt-1)/2;
if (num==1) ans1++,ans2*=cnt;
}
printf("Case %lld: %lld %lld\n",++cases,ans1,ans2);
}
}
0pts
cin >> m;