Answer to the question 3, with 4 test cases