Check each option by testing the ratio five years ago.
For 30 and 40, ages five years back were 25 and 35, and $25/35 = 5/7$. This matches the given condition.
For 24 and 32, five years back the ratio is $19/27$, not $5/7$.
For 12 and 16, the ratio is $7/11$, not $5/7$.
For 18 and 24, the ratio is $13/19$, not $5/7$.
Only the first pair works.
\[\boxed{30 \text{ and } 40 \text{ years}}\]