Initial version - TLE on test #14.
Code for problem 74D.