import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto str = line.chomp;
		if (str == "#") break;
		char[][] pat;

		void solve(char c, char[] dec) {
			if (c == 'a') {
				pat ~= dec;
				return;
			}

			foreach (i, s; dec) {
				if (s == c) return;
				if (s == c-1) {
					auto temp = dec.dup;
					temp[i] = c;
					solve((c -1).to!char, temp);
				}
			}
			solve((c -1).to!char, dec);
		}

		solve('z', str);

		pat = pat.sort;
		pat.length.writeln;
		if (pat.length < 10) {
			foreach (e; pat) {
				e.writeln;
			}
		} else {
			foreach (e; pat[0..5]) {
				e.writeln;
			}
			foreach (e; pat[pat.length-5..pat.length]) {
				e.writeln;
			}
		}
	}
}