#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int dis[N][N], v[N];
int main()
{
    for (int t = 1, x, y; scanf("%d%d", &x, &y), x | y; t++)
    {
        memset(dis, 0x3f, sizeof(dis));
        memset(v, 0, sizeof(v));
        do
        {
            v[x] = v[y] = 1;
            dis[x][y] = 1;
            scanf("%d%d", &x, &y);
        } while (x | y);
        for (int i = 0; i < N; i++)
            dis[i][i] = 0;
        for (int k = 0; k < N; k++)
            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
        long long sum = 0, cnt = accumulate(v, v + N, 0);
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                if (dis[i][j] != 0x3f3f3f3f)
                    sum += dis[i][j];
        printf("Case %d: average length between pages = %.3lf clicks\n", t, 1.0 * sum / cnt / (cnt - 1));
    }
    return 0;
}