funcao backtracking