#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int h[N], e[N], ne[N], idx;
int dfn[N], low[N], timestamp;
int stk[N], top;
vector<int> vdcc[N];
bool vg[N];
int vdcc_cnt;
int n, m, root;
void add(int a, int b)
{
e[idx] = b, ne[idx] = h[a], h[a] = idx ++;
}
void tarjan(int u)
{
dfn[u] = low[u] = ++ timestamp;
stk[++ top] = u;
if (u == root && h[u] == -1)
{
vdcc_cnt ++;
vdcc[vdcc_cnt].push_back(u);
return;
}
int cnt = 0;
for (int i = h[u]; ~i; i = ne[i])
{
int j = e[i];
if (!dfn[j])
{
tarjan(j);
low[u] = min(low[u], low[j]);
if (dfn[u] <= low[j])
{
cnt ++;
if (u != root || cnt > 1) vg[u] = true;
++ vdcc_cnt;
int y;
do{
y = stk[top --];
vdcc[vdcc_cnt].push_back(y);
} while (y != j);
vdcc[vdcc_cnt].push_back(u);
}
}
else low[u] = min(low[u], dfn[j]);
}
}
int main(void)
{
int T = 1;
while (scanf("%d", &m), m)
{
for (int i = 1; i <= vdcc_cnt; i ++)
vdcc[i].clear();
vdcc_cnt = idx = top = timestamp = n = 0;
memset(h, -1, sizeof h);
memset(dfn, 0, sizeof dfn);
memset(vg, 0, sizeof vg);
for (int i = 0; i < m; i ++)
{
int a, b;
cin >> a >> b;
n = max(n, a), n = max(n, b);
add(a, b), add(b, a);
}
for (root = 1; root <= n; root ++)
if (!dfn[root])
tarjan(root);
int res = 0;
unsigned long long int ans = 1;
for (int i = 1; i <= vdcc_cnt; i ++)
{
int cnt = 0;
for (int j = 0; j < vdcc[i].size(); j ++)
if (vg[vdcc[i][j]])
cnt ++;
if (cnt == 0)
{
if (vdcc[i].size() > 1) res += 2, ans *= vdcc[i].size() * (vdcc[i].size() - 1) / 2;
else res ++;
}
else if (cnt == 1) res ++, ans *= vdcc[i].size() - 1;
}
printf("Case %d: %d %llu\n", T, res, ans);
T ++;
}
return 0;
}