pythondef solve(N, S): from itertools import permutations rS = "".join(reversed(S)) for p in permutations(S): ret = "".join(p) if ret != S and ret != rS: return ret return "None"