# Elementary divisors for chains of submodules

Given free modules $N \le M$ of finite rank over a PID $R$, it's well-known that there is a basis $\{x_1,\ldots,x_n\}$ of $M$ and there are $e_1,\ldots,e_n \in R$ such that $\{e_ix_i\mid e_i \neq 0\}$ is a basis of $N$.

Now my question is, if this property also holds for chains of submodules.

Formally: Let $L \le N$ with $N,M$ as above. Is there a basis $\{ x_1, \ldots, x_n \}$ of $M$ and are there $e_i, f_i\in R$ such that $\{e_ix_i\mid e_i \neq 0\}$ is a basis of $N$ and $\{f_ie_ix_i\mid e_i\neq 0 \wedge f_i \neq 0\}$ is a basis of $L$ ?

This is true for fields but I have no idea if it also holds for all PIDs.

N.b. I asked this question on math.stackexchange some days ago but got no answer.

No. For example, let $R=\mathbb{Z}$, $M=\mathbb{Z}^2$, $N$ the subgroup generated by $(4,0)$ and $(2,1)$, and $L$ the subgroup generated by $(8,0)$ and $(0,2)$.
Then $M/N$ and $N/L$ are both isomorphic to $\mathbb{Z}/4\mathbb{Z}$, so if there were bases as described in the question, $M/L$ would have to be isomorphic to $\mathbb{Z}/16\mathbb{Z}$ or to $\mathbb{Z}/4\mathbb{Z}\oplus\mathbb{Z}/4\mathbb{Z}$.
But $M/L\cong\mathbb{Z}/8\mathbb{Z}\oplus\mathbb{Z}/2\mathbb{Z}$.
This example is based on the fact that there is a short exact sequence $$0\to\mathbb{Z}/4\mathbb{Z}\to\mathbb{Z}/8\mathbb{Z}\oplus\mathbb{Z}/2\mathbb{Z}\to\mathbb{Z}/4\mathbb{Z}\to0.$$