#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<iterator>
#include<string>
#include<sstream>
#include<cassert>
#include<ctime>
#define MP make_pair
#define PII pair<int,int>
#define PB push_back
#define X first
#define Y second
#define oo 2000000000
#define MOD 1000000007
#define LL long long int
using namespace std;
int N;
char tmp[22];
vector<string> array;
int L[22];
int dp[502];
int label[22][22];
PII val[502];
string ds[502];
int total_l;
bool isPrefix(int id1,int id2){
PII p1=val[id1];
PII p2=val[id2];
if((L[p1.X]-p1.Y) > (L[p2.X]-p2.Y) ) return false;
for(int i=0;i<L[p1.X]-p1.Y;i++){
if(array[p1.X][i+p1.Y] != array[p2.X][i+p2.Y]) return false;
}
return true;
}
int check(int id){
PII lb = val[id];
int &r = dp[id];
int tp;
if(r != -1 ) return r;
r = oo;
if(!lb.Y){
for(int i=0;i<N;i++){
if(i==lb.X) continue;
if(isPrefix(label[i][0],label[lb.X][0])){
tp = L[i]+check( label[lb.X][L[i]] );
if(tp >= oo) continue;
if(r > tp ) r = tp , ds[id] = array[i] + ds[label[lb.X][L[i]]];
else if(r == tp) ds[id] = min(ds[id],array[i] + ds[label[lb.X][L[i]]]);
}
else if(isPrefix(label[lb.X][0],label[i][0])){
tp = L[lb.X] + check( label[i][L[lb.X]] );
if(tp >= oo) continue;
if(r > tp) r = tp , ds[id] = array[lb.X] + ds[label[i][L[lb.X]]];
else if(r == tp) ds[id] = min(ds[id],array[lb.X]+ds[label[i][L[lb.X]]]);
}
}
return r;
}
for(int i=0;i<N;i++){
if(isPrefix(label[i][0],id)){
tp = L[i]+check( label[lb.X][lb.Y+L[i]] );
if(tp >= oo) continue;
if(r > tp) r = tp , ds[id] = array[i] + ds[label[lb.X][lb.Y+L[i]]];
else if(r == tp) ds[id] = min(ds[id] , array[i] + ds[label[lb.X][lb.Y+L[i]]]);
}
else if(isPrefix(id,label[i][0])){
tp = L[lb.X]-lb.Y+check( label[i][L[lb.X]-lb.Y] );
if(tp >= oo) continue;
if(r > tp) r = tp , ds[id] = array[lb.X].substr(lb.Y)+ds[label[i][L[lb.X]-lb.Y]];
else if(r == tp) ds[id] = min(ds[id] , array[lb.X].substr(lb.Y)+ds[label[i][L[lb.X]-lb.Y]] );
}
}
return r;
}
int main(){
//freopen("input.txt","r",stdin);
int T = 1;
while(scanf("%d",&N),N){
for(int i=0;i<N;i++){
scanf("%s",tmp);
array.PB(string(tmp));
}
sort(array.begin(),array.end());
for(int i=0;i<N;i++)
L[i]=array[i].length();
total_l=0;
for(int i=0;i<N;i++)
for(int j=0;j<L[i];j++){
label[i][j] = ++total_l , val[total_l] = MP(i,j);
}
++total_l;
for(int i=0;i<N;i++)
label[i][L[i]] = total_l;
for(int i=0;i<=total_l;i++)
dp[i]=-1 , ds[i] = string("");
dp[total_l]=0;
int ans=oo;
string ss;
for(int i=1;i<N;i++){
int tp = check(label[i][0]);
if(tp == oo) continue;
if(tp < ans) ans = tp ,ss = ds[label[i][0]];
else if(tp == ans) ss = min(ss , ds[label[i][0]]);
}
assert(ans != oo);
if(ans>1)
printf("Code %d: %d bits\n",T,ans);
else
printf("Code %d: %d bit\n",T,ans);
for(unsigned int i=0;i<ss.length();i++){
putchar(ss[i]);
if(i%20==19 || 1+i==ss.length()) puts("");
}
puts("");
++T;
array.clear();
}
return 0;
}
I2luY2x1ZGU8Y3N0ZGlvPgojaW5jbHVkZTxjc3RkbGliPgojaW5jbHVkZTxpb3N0cmVhbT4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTx2ZWN0b3I+CiNpbmNsdWRlPGNzdHJpbmc+CiNpbmNsdWRlPG1hcD4KI2luY2x1ZGU8c2V0PgojaW5jbHVkZTxzdGFjaz4KI2luY2x1ZGU8cXVldWU+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8aXRlcmF0b3I+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8c3N0cmVhbT4KI2luY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iZWxbaV1bMF0sbGFiZWxbbGIuWF1bMF0pKXsKICAgICAgICAgICAgICAgIHRwICA9IExbaV0rY2hlY2soIGxhYmVsW2xiLlhdW0xbaV1dICk7CiAgICAgICAgICAgICAgICBpZih0cCA+PSBvbykgY29udGludWU7CiAgICAgICAgICAgICAgICBpZihyID4gdHAgKSByID0gdHAgLCBkc1tpZF0gPSBhcnJheVtpXSArIGRzW2xhYmVsW2xiLlhdW0xbaV1dXTsKICAgICAgICAgICAgICAgIGVsc2UgaWYociA9PSB0cCkgZHNbaWRdID0gbWluKGRzW2lkXSxhcnJheVtpXSArIGRzW2xhYmVsW2xiLlhdW0xbaV1dXSk7CiAKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmKGlzUHJlZml4KGxhYmVsW2xiLlhdWzBdLGxhYmVsW2ldWzBdKSl7CiAgICAgICAgICAgICAgICB0cCA9IExbbGIuWF0gKyBjaGVjayggbGFiZWxbaV1bTFtsYi5YXV0gKTsKICAgICAgICAgICAgICAgIGlmKHRwID49IG9vKSBjb250aW51ZTsKICAgICAgICAgICAgICAgIGlmKHIgPiB0cCkgciA9IHRwICwgZHNbaWRdID0gYXJyYXlbbGIuWF0gKyBkc1tsYWJlbFtpXVtMW2xiLlhdXV07CiAgICAgICAgICAgICAgICBlbHNlIGlmKHIgPT0gdHApIGRzW2lkXSA9IG1pbihkc1tpZF0sYXJyYXlbbGIuWF0rZHNbbGFiZWxbaV1bTFtsYi5YXV1dKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gcjsKICAgIH0KICAgIGZvcihpbnQgaT0wO2k8TjtpKyspewogICAgICAgIGlmKGlzUHJlZml4KGxhYmVsW2ldWzBdLGlkKSl7CiAgICAgICAgICAgIHRwID0gTFtpXStjaGVjayggbGFiZWxbbGIuWF1bbGIuWStMW2ldXSApOwogICAgICAgICAgICBpZih0cCA+PSBvbykgY29udGludWU7CiAgICAgICAgICAgIGlmKHIgPiB0cCkgciA9IHRwICwgZHNbaWRdID0gIGFycmF5W2ldICsgZHNbbGFiZWxbbGIuWF1bbGIuWStMW2ldXV07CiAgICAgICAgICAgIGVsc2UgaWYociA9PSB0cCkgZHNbaWRdID0gbWluKGRzW2lkXSAsIGFycmF5W2ldICsgZHNbbGFiZWxbbGIuWF1bbGIuWStMW2ldXV0pOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmKGlzUHJlZml4KGlkLGxhYmVsW2ldWzBdKSl7CiAgICAgICAgICAgIHRwID0gTFtsYi5YXS1sYi5ZK2NoZWNrKCBsYWJlbFtpXVtMW2xiLlhdLWxiLlldICk7CiAgICAgICAgICAgIGlmKHRwID49IG9vKSBjb250aW51ZTsKICAgICAgICAgICAgaWYociA+IHRwKSByID0gdHAgLCBkc1tpZF0gPSBhcnJheVtsYi5YXS5zdWJzdHIobGIuWSkrZHNbbGFiZWxbaV1bTFtsYi5YXS1sYi5ZXV07CiAgICAgICAgICAgIGVsc2UgaWYociA9PSB0cCkgZHNbaWRdID0gbWluKGRzW2lkXSAsIGFycmF5W2xiLlhdLnN1YnN0cihsYi5ZKStkc1tsYWJlbFtpXVtMW2xiLlhdLWxiLlldXSApOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiByOwp9CiAKaW50IG1haW4oKXsKICAgIC8vZnJlb3BlbigiaW5wdXQudHh0IiwiciIsc3RkaW4pOwogICAgaW50IFQgPSAxOwogICAgd2hpbGUoc2NhbmYoIiVkIiwmTiksTil7CiAgICAgICAgZm9yKGludCBpPTA7aTxOO2krKyl7CiAgICAgICAgICAgIHNjYW5mKCIlcyIsdG1wKTsKICAgICAgICAgICAgYXJyYXkuUEIoc3RyaW5nKHRtcCkpOwogICAgICAgIH0KICAgICAgICBzb3J0KGFycmF5LmJlZ2luKCksYXJyYXkuZW5kKCkpOwogICAgICAgIGZvcihpbnQgaT0wO2k8TjtpKyspCiAgICAgICAgICAgIExbaV09YXJyYXlbaV0ubGVuZ3RoKCk7CiAgICAgICAgdG90YWxfbD0wOwogICAgICAgIGZvcihpbnQgaT0wO2k8TjtpKyspCiAgICAgICAgICAgIGZvcihpbnQgaj0wO2o8TFtpXTtqKyspewogICAgICAgICAgICAgICAgbGFiZWxbaV1bal0gPSArK3RvdGFsX2wgLCB2YWxbdG90YWxfbF0gPSBNUChpLGopOwogICAgICAgICAgICB9CiAgICAgICAgKyt0b3RhbF9sOwogICAgICAgIGZvcihpbnQgaT0wO2k8TjtpKyspCiAgICAgICAgICAgIGxhYmVsW2ldW0xbaV1dID0gdG90YWxfbDsKICAgICAgICBmb3IoaW50IGk9MDtpPD10b3RhbF9sO2krKykKICAgICAgICAgICAgZHBbaV09LTEgLCBkc1tpXSA9IHN0cmluZygiIik7CiAgICAgICAgZHBbdG90YWxfbF09MDsKICAgICAgICBpbnQgYW5zPW9vOwogICAgICAgIHN0cmluZyBzczsKICAgICAgICBmb3IoaW50IGk9MTtpPE47aSsrKXsKICAgICAgICAgICAgaW50IHRwID0gY2hlY2sobGFiZWxbaV1bMF0pOwogICAgICAgICAgICBpZih0cCA9PSBvbykgY29udGludWU7CiAgICAgICAgICAgIGlmKHRwIDwgYW5zKSBhbnMgPSB0cCAsc3MgPSBkc1tsYWJlbFtpXVswXV07CiAgICAgICAgICAgIGVsc2UgaWYodHAgPT0gYW5zKSBzcyA9IG1pbihzcyAsIGRzW2xhYmVsW2ldWzBdXSk7CiAgICAgICAgfQogICAgICAgIGFzc2VydChhbnMgIT0gb28pOwogICAgICAgIGlmKGFucz4xKQogICAgICAgICAgICBwcmludGYoIkNvZGUgJWQ6ICVkIGJpdHNcbiIsVCxhbnMpOwogICAgICAgIGVsc2UKICAgICAgICAgICAgcHJpbnRmKCJDb2RlICVkOiAlZCBiaXRcbiIsVCxhbnMpOwogICAgICAgIGZvcih1bnNpZ25lZCBpbnQgaT0wO2k8c3MubGVuZ3RoKCk7aSsrKXsKICAgICAgICAgICAgcHV0Y2hhcihzc1tpXSk7CiAgICAgICAgICAgIGlmKGklMjA9PTE5IHx8IDEraT09c3MubGVuZ3RoKCkpIHB1dHMoIiIpOwogICAgICAgIH0KICAgICAgICBwdXRzKCIiKTsKICAgICAgICArK1Q7CiAgICAgICAgYXJyYXkuY2xlYXIoKTsKICAgIH0KICAgIHJldHVybiAwOwp9