Problem 2 solved.
Problem 3 solve.d
Problem 4 solved.