Program successfully solves all test cases