Solved problem 1. Easy peasy!
Solved problem 2.