We have three cube-shaped containers. The edge of the second cube is $4 \mathrm{~cm}$ shorter than the edge of the first cube, and the edge of the third cube is $2 \mathrm{~cm}$ shorter than the edge of the second cube. We fill the second container from the first one, which is filled with water, and then we fill the third container from the second one. This way, the first container has $40 \mathrm{~cm}^{3}$ more water than three times the content of the second container. What is the volume of the three containers?
The edge length of the first cube (in cm) is denoted by $x$, the edge of the second cube is $x-4$, and that of the third is $x-6$, so their volumes (in $\mathrm{cm}^{3}$) are $x^{3}, (x-4)^{3}$, and $(x-6)^{3}$, respectively.

After the first pouring, the remaining volume of water in the first cube is $V=x^{3}-(x-4)^{3}$, and after the second pouring, the remaining volume of water in the second cube is $v=(x-4)^{3}-(x-6)^{3}$.

From the relationship $V=3 v+40$ between $V$ and $v$, we get an equation for $x$:

$$
x^{3}-(x-4)^{3}=3(x-4)^{3}-3(x-6)^{3}+40
$$

Rearranging this, a quadratic equation is formed, with roots $x_{1}=18, x_{2}=4$. The latter would result in a negative edge length for the third cube, which is not feasible. Therefore, the edge lengths of the cubes are 18, 14, and $12 \mathrm{~cm}$, and their volumes are 5832, 2744, and $1728 \mathrm{~cm}^{3}$, respectively.