Solution for Problem #1