(* This defines a new function that checks the cycle structure of a permutation. For example, the permutation π=(125)(3)(467) has 
a cycle type of {1,3,3} since it has one cycle of length 1 and two cycles of length 3. *)

ClearAll[CycleType];
CycleType[perm_List]:=Module[{cycles,visited,curr,next},cycles={};
visited=ConstantArray[False,Length[perm]];
Do[If[!visited[[i]],curr=i;
AppendTo[cycles,Reap[While[!visited[[curr]],visited[[curr]]=True;
Sow[curr];
curr=perm[[curr]];];][[2,1]]];];,{i,Length[perm]}];
Sort[Length/@cycles]]

(* The next command is an external function that converts permutations into their corresponding inversion table. The function is used below. *)

ResourceFunction["ToInversionVector"];

(* Next we use the CycleType function defined above to find all permutations with exactly one cycle. When M=6, this should yield (6-1)! = 120 such permutations. *)

ClearAll[cycleSignature,perms,M,res];
(* cycles=Join[ConstantArray[{2},2],{{3}}]; *)
cycleSignature[n_]:={{n}};
M=6;
perms=Permutations[Range[M]];
res=Select[perms,CycleType[#]==Flatten[cycleSignature[M]]&];
res

(* Finally, we convert each of the 120 permutations into their corresponding inversion tables and then compute the inversion numbers. Since M = 6, each inversion number must be odd. The last command searches the previous list for any even numbers and the ouput is empty, as expected. *)

invCollection=({{"[◼]", "ToInversionVector"}})/@res;
Plus@@#&/@invCollection
Select[%,EvenQ]

({{"[◼]", "ToInversionVector"}})[PermutationList[Cycles[{{2,6,4,5,1,3}}]]]

PermutationList[Cycles[{{4,1,5,3,2}}]]