Problem 025 rewritten