The retirement criteria for an employee in this organization is when their age plus years they've worked sums up to 77.
Mahesh is 37 years old at present. To find out how many more years Mahesh has to work before retirement, we need to subtract his current age from the retirement criteria, i.e., 77 - 37 = 40 years. So, Mahesh has 40 more years to work before he retires.
On the other hand, Suresh retires five years after Mahesh. At that time, Suresh's age will be 41 (current age) + 5 (years until Mahesh's retirement) = 46 years. Now, to find out how many years in total Suresh would have worked at the time of his retirement, we subtract his age at the time of Mahesh's retirement (46) from the retirement criteria (77), so: 77 - 46 = 31 years.
Therefore, when Mahesh retires, he would have worked for 40 years and Suresh would have worked for 31 years.