Solution for Part3