def is_on(S, j): 
    """
    Returns 1 if and only if the `j`-th item of the set `S` is on.

    Examples
    ========

    Check if the 3-th and then 2-nd item of the set is on:
    >>> S = 0b101010
    >>> is_on(S, 3), is_on(S, 2)
    (1, 0)

    """
    return (S & (1 << j)) >> j