def factor(n, p=2):
    """
    Compute n-1 = 2^s * d for strong psuedoprime and strong lucas psuedoprime.
    """
    s = 0
    n -= 1
    while not n % p:
        s += 1
        n //= p
    return s, n
