private int[][] GenerateAllPerms(){
		int[] indices = new int[n];//indices of permutation
		int size = nFactorial;
		int[][] Sn = new int[size][n+1];
		PermutationGenerator x = new PermutationGenerator (n);//generates the permutations
		int index = 0;
		while (x.hasMore ()) {//while there are more permutations
		  indices = x.getNext ();//the permutation in raw index form
		  for (int i = 0; i < indices.length; i++) {
			/*+1 accounts for fact that index starts at 0,
			  whereas the permutation starts at 1*/   
			  Sn[index][i+1] = indices[i] + 1;
		  }
		  index++;
		}
		return Sn;
	}