public class Lotto {
	
	public static Arquivo arquivo;
	private int[] numeros;
	
	private boolean[] mark;
	
	public Lotto(int n) {
		// le os numeros da entrada
		numeros = new int[n];
		for (int i = 0; i < n; i++)
			numeros[i] = arquivo.readInt();
	}
	
	public void print(int k) {
		mark = new boolean[numeros.length];
		for (int i = 0; i < numeros.length; i++)
			mark[i] = false;
		proc(0, k);
	}	
	
	private void proc(int pos, int k) {
		if (numeros.length - pos < k)
			return;
			
		// inclui o elemento
		mark[pos] = true;
		k--;
		
		// procura solucoes com o elemento
		if (k == 0) {
			// imprime o array
			for (int i = 0; i <= pos; i++)
				if (mark[i])
					arquivo.print(numeros[i] + " ");
			arquivo.println();
		} else {
			proc(pos+1, k);
		}
		
		// remove o elemento
		mark[pos] = false;
		k++;
		
		// procura solucoes sem o elemento
		proc(pos+1, k);
	}

	public static void main(String[] args) {
		arquivo = new Arquivo("lotto.in", "lotto.out");
		
		while (!arquivo.isEndOfFile()) {
			int n = arquivo.readInt(),
			    k = arquivo.readInt();
			Lotto lotto = new Lotto(n);
			lotto.print(k);
			arquivo.println();
		}
		arquivo.close();
	}
}