Solution (source code)

= Solution

From <Newton's law of universal gravitation>, $F=Gm_1m_2/r^2$, the <gravitational constant> has <physical dimension>
$$
\boxed{[G]=\frac{[F]L^2}{M^2}=M^{-1}L^3T^{-2}}.
$$
Here the two factors of <mass> and the inverse square of the separation determine the powers of $M$ and $L$.