Solved chapter 4 exercises