def METHOD_NAME(N):
    # Avoid various singularities
    if N==0:
        return (0,0)
    # Gallop to find bounds for line
    line = 1
    next = 2
    while base(next)<=N:
        line = next
        next = line << 1
    # Binary search for starting line
    lo = line
    hi = line<<1
    while lo + 1 != hi:
        #assert base(lo) <= N < base(hi)
        mid = (lo + hi)>>1
        if base(mid)<=N:
            lo = mid
        else:
            hi = mid
    line = lo
    return line, N - base(line)