class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
        int n = array[0].size();
        int m = array.size();
        for(int i = 0; i < n; i++) {
            if(array[0][i] > target)
                break;
            if(array[m-1][i] < target)
                continue;
            for(int j = 0; j < m; j++) {
                if(array[j][i] == target)
                    return true;
            }
        }
        return false;
    }
};