Permuting products of subgroups

Suppose $G$ is a group such that $G=H_1H_2$, then one can easily see that $G=H_2H_1$, one can switch the order of the subgroups: for a general element $g$ one writes $g^{-1}$ as $h_1h_2$ with $h_1\in H_1$ and $h_2\in H_2$ and then $g=h_2^{-1}h_1^{-1}$.

The question is the analogous for the general case with more subgroups: suppose $G$ is a group and $H_1$, $H_2$, ... ,$H_n$ are subgroups such that $G=H_1H_2\cdots H_n$. Is it always possible to permute the factors and still obtain the full group?

If one has the property that $H_1H_2\cdots H_i$ is a subgroup of $G$ for every $i$ then one can use induction and the case with two subgroups to show that it is always possible, but this condition may not always hold.

• Note that the existence of a counterexample was easily predictable, since otherwise this would imply that if a finite group $G$ is generated by subgroups $H,K$, so that $G=HKHKHK\dots HK$ for enough many factors, then by permuting we get $G=H\dots HK\dots K$ and thus $G=HK$. Thus it's enough to find the smallest possible examples, which, no surprisingly, is the smallest non-abelian group. This is why I voted to migrate on MathSE, it's not of research level. – YCor Nov 3 '14 at 15:23

Take $G=\textrm{Sym}(3)$ and $H_1=H_3=\langle (12)\rangle$ and $H_2=\langle (23)\rangle$. Then $H_1H_2H_3=G$ but $H_1H_3H_2=H_1H_2\subsetneq G$.