Artificial intelligent assistant

Creating pairs of homo-, bi- and heterosexual boys and girls Consider a set of boys and girls. A person can be either homo-, hetero- or bisexual so that they want to be with members of their own gender, the other gender or are indifferent towards gender. How can I create pairs of these people so that each person wants to be with their partner? Is it possible to easily check if a solution exists?

1) If the total number is not even, it won't work.

2) If there is an odd number of male homosexuals but no male bisexual, it won't work.

3) If there is an odd number of female homosexuals but no female bisexual, it won't work.

If these problems don't occur, marry off all the homosexuals using possibly one bisexual in either gender.

The remaining even number of heterosexual and bisexual people may have an overhang of one gender. This difference $d$ is even.

4) If there are less than $d$ bisexuals in the more frequent remaining gender, it won't work.

If there are (at least) $d$ bisexuals in the more frequent remaining gender, then marry them off and finally form heterosexual marriages with the rest.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 799e8c82e77e668eda1b103d3d4859a5