Solutions for problems 4, 5, 6