I have trouble solving the following two matrix equations for unknown $X \in \mathbb{R}^{n \times n}$: $$X^T A X = B_1$$ $$X A X^T = B_2$$ where, $A$, $B_1$ and $B_2$ are all $n \times n$ symmetric matrices such that $A^n = I_n$, and $B_1 \neq B_2$
There is a solution for $X$ if $A$ and the $B$'s are positive-definite, but is there an analytical solution for any matrices?
Edit: Is there a way to solve this when $A^n \neq I_n$? I'm interested in the case where $A$, $B_1$, $B_2$ and $X$ are matrices of one-to-one mappings, i.e., $A_{ij}=A_{ji}=1$ if $i$ maps to $j$, and $0$ otherwise. For example: $$A = \begin{bmatrix} 0 & 1 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0\\ 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 \end{bmatrix}$$