def apply_mask(xy):
    """
    Apply bitmask to value.

    Args:
    xy: A tuple with the bit of the mask
    and the bit to mask (mask, value).

    Returns:
    The bit after being masked.
    """
    if xy[0] == 'X':
        return xy[1]
    else:
        return xy[0]