Let $G$ be a group and $A,B\leq G$ abelian subgroups such that $AB=G$. Show $A\cap B\leq Z(G)$ I am working on an exercise that states:

Let $G$ be a group and $A,B\leq G$ abelian subgroups such that $AB=G$. Show $A\cap B\leq Z(G)$.

My attempt so far:
$Z(G)=\{z \in G \mid \forall g \in G, zg = gz\}$
Because $A,B\leq G$ are abelian subgroups $A\cap B\leq G$ is an abelian subgroup.
Can anyone give me a hint?
 A: Let $x \in A \cap B$ and let $g=ab \in G$ arbitrary, with $a \in A, b \in B$. Then $xab=$ (using $A$ is abelian, and $x \in A$) $axb=$ (using $B$ is abelian and $x \in B$) $=abx$. Hence $x \in Z(G)$.

Note (added June $23^{rd} 2022$) A famous theorem of N. Itô, dating from $1955$, states that if a group $G=AB$ with $A$ and $B$ both abelian subgroups, then $G'$ must be abelian ($G$ is called metabelian). This is not hard to prove, read the paper in the link (warning: in German, but the formulas are easy to follow).
A: I will use the one-step subgroup test.
Since $A,B\le G$, they are themselves groups and their identity is the identity in $G$. Thus $e\in A\cap B$. Hence $A\cap B\neq\varnothing$.
Since $A$ and $B$ are abelian, all elements $x$ of $A\cap B$ commute with all elements of $ A$ and of $B$. But $G=AB$, so that all $g\in G$ can be written as $g=ab$, with $a\in A$ and $b\in B$, so
$$\begin{align}
xg&=x(ab)\\
&=(xa)b\\
&=(ax)b\\
&=a(xb)\\
&=a(bx)\\
&=(ab)x\\
&=gx,
\end{align}$$
meaning $x\in Z(G)$. Hence $A\cap B\subseteq Z(G)$.
Let $h,k\in A\cap B$. Since $A\cap B\le G$ (as $A,B\le G$), we have, in particular, that $hk^{-1}\in A\cap B$.
Hence $A\cap B\le Z(G)$.
