void generate(int n, int m) {
		List<Integer> segEnd = new ArrayList<Integer>();
		for (int i = 0; i < n - 1; i++) {
			segEnd.add(i);
		}
		Combination<Integer> combn = new CombinationImpl<Integer>(segEnd, m - 1);

		for (List<Integer> lastPos : combn) {
			Integer[] codeSeed = new Integer[n];
			lastPos.add(0, -1);
			lastPos.add(n - 1);

			// lastPos : ascending position number. In the case of f(4,3), the
			// first lastPos is {-1,0,1,3}
			for (int i = 0; i < m; i++) {
				// current segment is in range ( loasPos[i]+1, lastPos[i+1] )
				for (int j = lastPos.get(i) + 1; j <= lastPos.get(i + 1); j++) {
					codeSeed[j] = i;
				}
			}

			// codeSeed : the ascending coding. In the case of f(4,3), the first
			// codeSeed is {0,1,2,2}
			Permutation<Integer> perm = new PermutationImpl<Integer>(codeSeed);

			// get all matrixes based on the seed code.
			for (Integer[] code : perm) {
				System.out.println(StringUtils.join(code, ","));
			}
		}
	}