The matrix has rank $n$ if and only if $A$ is nonsingular and $B = A^{-1}$. Let $A$ and $B$ be $n \times n$ matrices with real entries. Show that the
matrix $$M = \left( \begin{matrix} A&I\\ I&B \end{matrix} \right)$$
 has rank $n$ if and only if $A$ is nonsingular
and $B = A^{-1}$.

Totally stuck on it. Can I get some help.Thanks for your time.
 A: By Gaussian elimination $\pmatrix{
A& I\\
I& B
}$ can be changed to $\pmatrix{0&I-BA\\ I& B } $, whose rank is $n$, so $I-AB=0$.
A: $$\left( \begin{matrix} I&O\\ -B&I \end{matrix} \right)\left( \begin{matrix} A&I\\ I&B \end{matrix} \right)=\left( \begin{matrix} A&I\\ I-BA&O \end{matrix} \right)$$So $I-BA=O$.
A: Since the first $n$ columns of $M$ are linearly independent and since the column rank of $M$ is $n$, the last $n$ columns of $M$ are linear combinations of the first $n$ columns. That is to say, there exists an $n\times n$ matrix $T$, such that
$$\begin{pmatrix}I\\ B\end{pmatrix}=\begin{pmatrix}A\\ I\end{pmatrix}\cdot T=\begin{pmatrix}AT\\ T\end{pmatrix}\Rightarrow B=T=A^{-1}.$$
A: if $M$ has n rank then it  is non singular then $Mx=0$ must have null sace with dimesion of $n$ so $M = \left( \begin{matrix} A&I\\ I&B \end{matrix} \right)\left( \begin{matrix} x_1\\x_2\\\\\\\\\\x_n\\x_{n+1}\\\\\\\\\\\ x_{2n} \end{matrix} \right)=0$  must have null space with dimension n (since it's rank is n)
we result that 
1)$A\left( \begin{matrix} x_1\\x_2\\\\\\\\\\x_n\end{matrix} \right)+I\left( \begin{matrix} x_{n+1}\\\\\ \\\\\\\\\\ x_{2n} \end{matrix} \right)=0$
and 
2)$I\left( \begin{matrix} x_1\\x_2\\\\\\\\\\x_n\end{matrix} \right)+B\left( \begin{matrix} x_{n+1}\\\\\ \\\\\\\\\\ x_{2n} \end{matrix} \right)=0$
each of 1 and 2 has solution space with dime n then they must be linear depend (on the other word they must result each other)and it is possible obviously if and only if $B=A^{-1}$
and reverse is similar
