Matrix Search problem

my code is unable to pass the 2nd test case why??
please help me out

your solution shouldn’t pass with the given time constraints as you are using n * m time. What you should do is iterate over every row and check if the number can be present in this row checking the minimum and maximum value in every row and if it is , just binary search the element in that row. Complexity n log m