def _apply_mask(_m, _val):
    """
    Given a mask `_m` that is
    a string of 36 bits each '0',
    '1' or 'X', apply it to a given
    value.

    :param _m: The mask string
    :param _val: A value to be masked.

    :return: The uniqued masked value.

    """
    _v = str(bin(int(_val)))[2:]

    _v = ["0"] * (36 - len(_v)) + list(_v)

    for _i in range(len(_m)):
        if _m[_i] == "X":
            continue
        else:
            _v[_i] = _m[_i]
    _res = "".join(_v)

    return int(_res, 2)