private int searchBottom(char[][] image, int x) {
        int low = x, high = image.length - 1;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            int i = 0;
            while (i < image[0].length && image[mid][i] == '0') ++i;
            if (i < image[0].length) low = mid + 1;
            else high = mid - 1;
        }
        return high;
    }