def generate_masks(raw):
    """ Create "and" masks and "or" masks for all possible combinations of
    "floating" bits ("X" bits can be either 0 or 1) """
    masks = []
    numx = raw.count("X")
    bits = list(raw)
    for variant in range(2**numx):
        mask = list(f"{bin(variant)[2:]:0>{numx}}")
        maskbits = bits.copy()
        amask = ["1"] * 36
        maskindex = 0
        for i, bit in enumerate(bits):
            if bit == "X":
                maskbits[i] = mask[maskindex]
                if mask[maskindex] == "0":
                    amask[i] = "0"
                maskindex += 1
        omask = int("".join(maskbits), 2)
        amask = int("".join(amask), 2)
        masks.append((omask, amask))
    return masks