def extractTwos(m):
    """m is a positive integer. A tuple (s, d) of integers is returned
    such that m = (2 ** s) * d."""
    assert m >= 0
    i = 0
    while m & 2 ** i == 0:
        i += 1
    return i, m >> i
