#include<stdio.h>
#include<string.h>
#define N 2001
int grah[N][N];
int sum;
void prim(int n)
{
int i,j,pos;
int min,v[2001]={0},d[2001];
for(i=0;i<n;i++)
d[i]=grah[0][i];
v[0]=1;
for(i=1;i<n;i++)
{
min=99999999;
for(j=0;j<n;j++)
{
if(!v[j]&&min>d[j])
{min=d[j];pos=j;}
}
sum+=min;
v[pos]=1;
for(j=0;j<n;j++)
{
if(!v[j])
{
if(d[j]>grah[pos][j])
d[j]=grah[pos][j];
}
}
}
}
int main()
{
int n;
char str[N][8];
// freopen("e:\\2.txt","r",stdin);
while(scanf("%d",&n),n)
{
int i,j,s,k;
for(i=0;i<n;i++)
scanf("%s",str+i);
for(i=0;i<n;i++)
for(j=i;j<n;j++)
{
s=0;
for( k=0;k<7;k++)
if(str[i][k]!=str[j][k])
s++;
grah[i][j]=grah[j][i]=s;
}
sum=0;
prim(n);
printf("The highest possible quality is 1/%d.\n",sum);
}
return 0;
}
#include<string.h>
#define N 2001
int grah[N][N];
int sum;
void prim(int n)
{
int i,j,pos;
int min,v[2001]={0},d[2001];
for(i=0;i<n;i++)
d[i]=grah[0][i];
v[0]=1;
for(i=1;i<n;i++)
{
min=99999999;
for(j=0;j<n;j++)
{
if(!v[j]&&min>d[j])
{min=d[j];pos=j;}
}
sum+=min;
v[pos]=1;
for(j=0;j<n;j++)
{
if(!v[j])
{
if(d[j]>grah[pos][j])
d[j]=grah[pos][j];
}
}
}
}
int main()
{
int n;
char str[N][8];
// freopen("e:\\2.txt","r",stdin);
while(scanf("%d",&n),n)
{
int i,j,s,k;
for(i=0;i<n;i++)
scanf("%s",str+i);
for(i=0;i<n;i++)
for(j=i;j<n;j++)
{
s=0;
for( k=0;k<7;k++)
if(str[i][k]!=str[j][k])
s++;
grah[i][j]=grah[j][i]=s;
}
sum=0;
prim(n);
printf("The highest possible quality is 1/%d.\n",sum);
}
return 0;
}