P5 Math: Uneven Ratio becomes Equal after Both Decrease

This question provides the ratio of 2 items at first.
After both undergo different decrease in value, both ends up being equal with one another.

Such questions are common in WA2(mid year) for P5.
Calculator usage may be allowed.

A similar but "inverted" version of this question can also be found "here".

Alan and Rick each have pencils in the ratio of 5:8.
After Alan gave away 32 pencils and Rick sold 77 pencils.
They have equal number of pencils remaining.

How many pencils did Rick have at the end?


If the above question is easy, try to do the more challenging question below.

The question below will randomize with different numbers every hour. 
Copy below question down before making attempt.


Click if above box appears blank