Let A's present age be x years.
Let B's present age be y years.
A's age 5 years ago = (x − 5) years
B's age 5 years ago = (y − 5) years
Then, we have:
(x − 5) = 3(y − 5)
⇒ x − 5 = 3y − 15
⇒ x − 3y = −10 ....(i)
A's age 10 years later = (x + 10) years
B's age 10 years later = (y + 10) years
Then, we have:
(x + 10) = 2(y + 10)
⇒ x + 10 = 2y + 20
⇒ x − 2y = 10 ....(ii)
On subtracting (ii) from (i), we get:
−y = −20
⇒ y = 20
On substituting y = 20 in (i), we get:
x − 3 × 20 = −10
⇒ x − 60 = −10
⇒ x = (−10 + 60) = 50
⇒ x = 50
Hence, A's present age is 50 years and B's present age is 20 years.