Implemented cache for problem 14.