#include using namespace std; typedef struct lol { int N; string s; friend bool operator < (const lol &first,const lol &second) { if(first.N==second.N) return first.ssecond.N; } }troll; typedef struct state { int link,len; map next; }State; int i,n,j,sz,last,now,magic; bool ok; string s,rs,curr_rs; troll a[1000005]; State sa[2000005]; void add_letter(char c) { int now=sz++,p; sa[now].len=sa[last].len+1; for(p=last;p!=-1 && !sa[p].next.count(c);p=sa[p].link) sa[p].next[c]=now; if(p==-1) sa[now].link=0; else { int q=sa[p].next[c]; if(sa[p].len+1==sa[q].len) sa[now].link=q; else { int clone=sz++; sa[clone].next=sa[q].next; sa[clone].len=sa[p].len+1; sa[clone].link=sa[q].link; for(;p!=-1 && sa[p].next[c]==q;p=sa[p].link) sa[p].next[c]=clone; sa[q].link=sa[now].link=clone; } } last=now; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); while(cin>>s) a[++n].s=s,a[n].N=a[n].s.length(); for(magic=1;magic<=10;++magic) { if(magic==1) sort(a+1,a+n+1); else random_shuffle(a+1,a+n+1); for(i=1;i<=n;++i) { for(j=0,ok=1,now=0;j