string permutations using backtracking