Two finitely generated module over $\mathbb{C}[[x_1, x_2, \dots, x_n]]$ I'm struggling with the following problem.

Let $A = \mathbb{C}[[x_1, x_2, \dots, x_n]]$  be the ring of formal power series over $\mathbb{C}$.
Show that if two finitely generated $A$-modules $M, N$ satisfy $M\otimes_AN \cong A$ as $A$-modules, then $M \cong N \cong A$.

The part I managed to prove is as follows.
Since $A$ is the local ring with the maximal ideal $m=(x_1, x_2, \dots,x_n)$ and the residue field $k = A/m \cong \mathbb{C}$, $M_k \otimes_k N_k = (M \otimes_A k) \otimes_k (N \otimes_A k) \cong (M \otimes_A N) \otimes_A k \cong A \otimes_A k \cong k$ as $k$-Vector space.
Thus the dimensions of $M_k = M \otimes_A k$ and $N_k = N \otimes_A k$ as $k$-Vector space are both $1$.
So if I could prove that $M$ is free $A$-Module with the finite rank $r$, it follows that $M \cong A$ from $k \cong A^r \otimes_A k \cong (A \otimes_A k)^r \cong k^r$, so is $N$.
How can I prove that $M$ is free?
I think it may be related to the fact that $A$ is Noetherian local ring.
(In this case it suffices to show that $M$ is flat (Atiyah-Macdonald Exercise 7-15), or $M$ is finitely generated projective module over a local ring.)
 A: Given that $M$ and $N$ are finitely generated, we have that $M = A \langle x_1, \dots, x_m \rangle$ for some elements $x_i$ in $M$ and $N = A \langle y_1, \dots, y_n \rangle$ for some elements $y_j$ in $N.$ Consider the surjections $\pi : A^m \to M$ and $\rho : A^n \to N$ defined by $\pi(r_1, \dots, r_m) = r_1 x_1 + \cdots + r_m x_m$ and $\rho(r_1, \dots, r_n) = r_1 y_1 + \cdots + r_n y_n.$ Recall that the functors $M \otimes_A -$ and $- \otimes_A N$ are right-exact, hence we have surjections $\pi \otimes_A 1_N : A^m \otimes_A N \to M \otimes_A N$ and $1_M \otimes_A \rho : M \otimes_A A^n \to M \otimes_A N.$ By hypothesis that there exists an isomorphism $\varphi : M \otimes_A N \to A,$ it follows that $\varphi \circ (\pi \otimes_A 1_N) : A^m \otimes_A N \to A$ and $\varphi \circ (1_M \otimes_A \rho) : M \otimes_A A^n \to A$ are surjections. Certainly, $A$ is a free $A$-module, hence the maps $\varphi \circ (\pi \otimes_A 1_N)$ and $\varphi \circ (1_M \otimes_A \rho)$ split, i.e., there exist $A$-modules $M'$ and $N'$ such that $M \otimes_A A^n \cong M' \oplus A$ and $A^n \otimes_A M \cong A \oplus N'.$ Putting this all together gives $$A^n \cong (M \otimes_A N) \otimes_A A^n \cong N \otimes_A (M \otimes_A A^n) \cong N \otimes_A (M' \oplus A) \cong N \oplus (N \otimes_A M'),$$ and analogously, we have that $A^m \cong M \oplus (M \otimes_A N').$ Consequently, both $M$ and $N$ are direct summands of a free $A$-module, so they are projective $A$-modules. But a finitely generated projective module over a Noetherian local ring is free, so we are done.
