/**
 * got TLE... running time = 11 sec., but limit = 8 sec.
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define L 20
#define N (1<<L)

char cands_fw[5][L+1];
int cands_fw_ok[5];
char cands_bw[5][L+1];
int cands_bw_ok[5];
int fw_nok, bw_nok, nok;

int main(int argc, char *argv[])
{
  char buf[L+2];
  int i, j, k;
  for(;;){
    int l, n, i_fw;
    fgets(buf, L+2, stdin);
    l = strlen(buf) - 1;
    buf[l] = 0;  // to remove the newline
    n = 1 << l;
    if(buf[0]=='#') break;
    nok = 0;
    // forward
    fw_nok = 0;
    for(i = 0; i < n; i++) {
      char exec[L+1];
      char cand[L+1];
      for(j = 0; j < l; j++) {
        cand[j] = buf[j] + (((1<<(l-1-j)) & i) ? 1 : 0);
        exec[j] = cand[j];
      }
      cand[l] = 0;
      exec[l] = 0;
      //printf("cand = %s\n", cand);
      for(k = 0; k < 25; k++) {
        char c1 = 'a' + k;
        char c2 = c1 + 1;
        for(j = 0; j < l; j++) {
          if(exec[j] == c2) {
            exec[j] = c1;
            break;
          }
        }
      }
      //printf("exec = %s\n", exec);
      if(strcmp(exec, buf) == 0) {
        char *candsi = cands_fw[fw_nok];
        for(j = 0; j <= l; j++) {
          candsi[j] = cand[j];
        }
        fw_nok++;
        nok++;
        if(fw_nok == 5) break;
      }
    }
    i_fw = i;
    // backward
    bw_nok = 0;
    for(i = n - 1; i > i_fw; i--) {
      char exec[L+1];
      char cand[L+1];
      for(j = 0; j < l; j++) {
        cand[j] = buf[j] + (((1<<(l-1-j)) & i) ? 1 : 0);
        exec[j] = cand[j];
      }
      cand[l] = 0;
      exec[l] = 0;
      //printf("cand = %s\n", cand);
      for(k = 0; k < 25; k++) {
        char c1 = 'a' + k;
        char c2 = c1 + 1;
        for(j = 0; j < l; j++) {
          if(exec[j] == c2) {
            exec[j] = c1;
            break;
          }
        }
      }
      //printf("exec = %s\n", exec);
      if(strcmp(exec, buf) == 0) {
        if(bw_nok < 5) {
          char *candsi = cands_bw[bw_nok];
          for(j = 0; j <= l; j++) {
            candsi[j] = cand[j];
          }
          bw_nok++;
        }
        nok++;
      }
    }
    printf("%d\n", nok );
    for(i = 0; i < fw_nok; i++) {
      printf("%s\n", cands_fw[i]);
    }
    for(i = bw_nok - 1; i >= 0; i--) {
      printf("%s\n", cands_bw[i]);
    }
  }
  return 0;
}