This version works for all 4 test cases