// Arup Guha
// 2/4/2017
// Written in Junior Knights to Introduce Brute Force

import java.util.*;

public class bruteforce {

	final public static int SIZE = 4;

	public static void main(String[] args) {
		// Add items as needed to call other methods.
		char[] word = new char[5];
		upwords(word, 3, 0);
	}

	// Prints an odometer with the first k digits in list fixed.
	public static void odometer(int[] list, int k) {

		// Done filling it in.
		if (k == list.length)
			print(list);
			
		// Try each possible item in slot k, in numeric order, and recurse.
		else {
			for (int i=0; i<10; i++) {
				list[k] = i;
				odometer(list, k+1);
			}
		}
	}

	// Prints out all permutations of [0,1,...,list.length()-1] with first k items fixed.
	// used must be such that used[i] == true iff i was previously used in the permutation.
	public static void printPerm(int[] list, boolean[] used, int k) {

		// Done filling it in.
		if (k == list.length)
			print(list);
			
		else {
			
			// Try each item.
			for (int i=0; i<list.length; i++) {
				
				// Skip used ones.
				if (used[i]) continue;
				
				// Fill in, mark as used, recurse, then mark as unused.
				list[k] = i;
				used[i] = true;
				printPerm(list, used, k+1);
				used[i] = false;
			}
		}
	}

	// Prints out all derangements of [0,1,...,list.length()-1] with first k items fixed.
	// used must be such that used[i] == true iff i was previously used in the permutation.
	public static void printDerangements(int[] list, boolean[] used, int k) {

		// Done!
		if (k == list.length)
			print(list);
			
		else {
			
			// Try everything.
			for (int i=0; i<list.length; i++) {
				
				// Skip used items and items in their "original" slot.
				if (used[i] || i == k) continue;
				
				// Same as permutation...
				list[k] = i;
				used[i] = true;
				printDerangements(list, used, k+1);
				used[i] = false;
			}
		}
	}

	// Prints upwords of length word.length with a skip of at least skip with first k letters fixed.
	public static void upwords(char[] word, int skip, int k) {

		// Done.
		if (k == word.length) {
			System.out.println(new String(word));
		}
		
		// Recursive case.
		else {
			
			// Calculate first possible character for slot k.
			char start = 'a';
			if (k > 0)
				start =  (char)(word[k-1] + skip + 1);
				
			// Try everything that could be in this slot and recurse.
			for (; start <= 'z'; start++) {
				word[k] = start;
				upwords(word, skip, k+1);
			}

		}
	}

	public static void print(int[] list) {
		for (int i=0; i<list.length; i++)
			System.out.print(list[i]+" ");
		System.out.println();
	}
}