To reach the winning post, A will have to cover a distance of (500 - 140). i.e, 360 m.
While A covers 3 m, B covers 4 m.
While A covers 360 m, B covers 4 × 360 / 3 = 480 m.
So, A reaches the winning post while B remains 20 meter behind.
∴ A wins by 20 m.