def search_column(l: int, r: int, up: bool) -> int:
    k = (r if up else l)
    while (l <= r):
        (mid, mid_k) = (((l + r) >> 1), 0)
        for i in range(m):
            if (image[mid][i] == '1'):
                mid_k = 1
                break
        if mid_k:
            k = (min(k, mid) if up else max(k, mid))
        if (mid_k ^ up):
            l = (mid + 1)
        else:
            r = (mid - 1)
    return k
def search_column(l: int, r: int, up: bool) -> int:
    k = (r if up else l)
    while (l <= r):
        (mid, mid_k) = (((l + r) >> 1), 0)
        for i in range(m):
            if (image[mid][i] == '1'):
                mid_k = 1
                break
        if mid_k:
            k = (min(k, mid) if up else max(k, mid))
        if (mid_k ^ up):
            l = (mid + 1)
        else:
            r = (mid - 1)
    return k