#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int maxn = 1000000;
char dic[2024*1024];
char *word[1024*1024];
int wordn=0;
int main(int argv, char **argc){
    int I=0;
    char s[16];
    srand(argv >= 3 ? atoi(argc[3]) : 0);
    int maxtest = (argv >= 2 ? atoi(argc[2]) : 0);
    for(I=(argv >= 1 ? atoi(argc[1]) : 0); I <= maxtest;I++){
        sprintf(s, "%02d", I);
        freopen(s,"w",stdout);
        while(!wordn || word[wordn-1]-dic + strlen(word[wordn-1]) < maxn){
            if(!(rand() & 0x3f) || wordn < 10){
                int len = (rand()&7) + 5;
                word[wordn] = wordn ? word[wordn-1]+strlen(word[wordn-1])+1 : dic;
                for(int i=0;i<len;i++){
                    word[wordn][i] = rand() % ('z' - 'a' + 1) + 'a';
                }
                word[wordn][len]=0;
                wordn++;
            }
            else{
               int j = (rand()+rand()*RAND_MAX)%wordn, i;
               int len = (rand()&7) + 5, lw = strlen(word[j]);
               word[wordn] = word[wordn-1]+strlen(word[wordn-1])+1;
               for(i=0;i<lw;i++)
                    word[wordn][i] = word[j][i];
               int rc = (rand()&13);
               i-= rc == 12 ? 0 : (rc>>2) + 1;
               for(;i<len;i++){
                   word[wordn][i] = rand() % ('z' - 'a' + 1) + 'a';
               }
               word[wordn][len]=0;
               if((rand()&3) == 0)
                   word[wordn][len-1] = rand() % ('z' - 'a' + 1) + 'a';
               wordn++;
            }
        }
        wordn--;
        int len=0;
        while(len<maxn){
            int w = (rand()+rand()*RAND_MAX)%wordn;
            if(strlen(word[w]) + len > maxn)
                len = maxn;
            else{
                for(int i=0;word[w][i];i++){
                    putchar(((rand() & 0x3) == 0) ? (rand() % ('z' - 'a' + 1) + 'a') : word[w][i]);
                    len++;
                }
            }
        }
        putchar('\n');
        printf("%d\n", wordn);
        for(int i=0;i<wordn;i++)
            puts(word[i]);
    }
    return 0;
}
