import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NameGen {
    
    final static String VOWELS = "aeiou";
    final static String CONSONANTS = "bcdfghjklmnpqrstvwxyz";

    static void usage() {
	System.err.println("NameGen <length of words> <number of words> [regex filter]");
	System.err.println("Example: NameGen 6 10 \".*mido\"");
    }

    public static void main (String[] args) {
	int num, len;
	Random r = new Random();
	boolean checkRegEx;
	Pattern pattern = null;
	Matcher matcher = null;
	char[] currentWord;
	int matchesFound = 0;

	if (args.length < 2 || args.length > 3) {
	    usage();
	    System.exit(1);
	}

	len = Integer.parseInt(args[0]);
	len += len %2;
	num = Integer.parseInt(args[1]);
	checkRegEx = args.length == 3;
	if (checkRegEx) {
	    pattern = Pattern.compile(args[2]);
	}
	
	currentWord = new char[len];
	do {
	    for (int j = 0; j<len/2; j++) {
		currentWord[j*2] = CONSONANTS.charAt(r.nextInt(CONSONANTS.length()));
		currentWord[j*2+1] = VOWELS.charAt(r.nextInt(VOWELS.length()));
	    }
	    String currentWordStr = new String(currentWord);
	    if (checkRegEx && !pattern.matcher(currentWordStr).matches())
		continue;
	    matchesFound++;
	    System.out.println(currentWord);
	} while (matchesFound < num);
    }

}
