n=10;
Print[{
MatrixForm[A=Array[
If[#1==#2, 0, Random[Integer, {0,1}]]&,
{n,n}
]],
v=Table[2*Random[Integer, {0,1}]-1, {n}],
MatrixForm[BB = (X^v-1)*A],
Det[IdentityMatrix[n]-BB] // Together // ExpandDenominator // ExpandNumerator,
MatrixForm[CC = v*A+DiagonalMatrix[v]],
Z=Tr[Inverse[IdentityMatrix[n]-BB].BB.CC] // Together // ExpandDenominator // ExpandNumerator,
Exp[-Integrate[Z/X,X]] // Together // ExpandDenominator // ExpandNumerator
}]

wAlex[GC[Ar[1,3,+1], Ar[2,5,-1], Ar[6,4,+1]]]/x// Together // ExpandDenominator // ExpandNumerator

n=3;
Print[{
A=(({{0, 0, 0}, {1, 0, 1}, {0, 1, 0}})),
v={-1,1,1},
MatrixForm[BB = (X^v-1)*A],
MatrixForm[CC = v*A+DiagonalMatrix[v]],
Tr[Inverse[IdentityMatrix[n]-BB].BB.CC] // Together // ExpandDenominator // ExpandNumerator
}]

Exp[-Integrate[(((2-2 X)/(-2+X)))/X,X]] // Simplify