naive solution to searchMatrix