#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 2005;
const int Mod = 1000000007;
const int inf = 1<<30;
int n;
char str[maxn][10];
bool vis[maxn];
int map[maxn][maxn],dis[maxn];
int GetDis( char *a,char *b )
{
int ans = 0;
for( int i = 0; i < 7; i ++ )
{
if( a[i] != b[i] )
ans ++;
}
return ans;
}
int Prime( int s )
{
int ans = 0;
memset( vis,0,sizeof(vis) );
for( int i = 1; i <= n; i ++ )
dis[i] = map[s][i];
vis[s] = 1;
for( int i = 1; i < n; i ++ )
{
int Min = inf,p = s;
for( int j = 1; j <= n; j ++ )
{
if( !vis[j] && dis[j] < Min )
Min = dis[p = j];
}
if( vis[p] ) continue;
vis[p] = true;
ans += Min;
for( int j = 1; j <= n; j ++ )
{
if( map[p][j] < dis[j] )
dis[j] = map[p][j];
}
}
return ans;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
while( scanf("%d",&n) != EOF,n )
{
getchar();
for( int i = 1; i <= n; i ++ )
scanf("%s",str[i]);
for( int i = 1; i <= n; i ++ )
{
map[i][i] = 0;
for( int j = i+1; j <= n; j ++ )
{
map[i][j] = map[j][i] = GetDis( str[i],str[j] );
}
}
printf("The highest possible quality is 1/%d.\n",Prime(1));
}
return 0;
}