MMO 2015 Problem 5

MMO 2015 PROBLEM 5

Solution