wyuan; holstein; The data is very small. Simply DFS or BFS is OK. Let's try http://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation to generate a binay code of combination.