Solved the third problem