sherlock and permutations problem solved