4. From 9 classmates, select 5 to form the class committee, requiring that A and B either both be selected or both not be selected, and C and D not be selected at the same time. The number of selection methods that meet the requirements is $\qquad$ (answer with a number).

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
4. 41.

When A and B are both selected, there are $\mathrm{C}_{7}^{3}=35$ ways to choose the other members, and among these, the number of ways in which C and D are both selected is $\mathrm{C}_{5}^{1}=5$; When A and B are both not selected, there are $\mathrm{C}_{7}^{5}=21$ ways to choose the other members, and among these, the number of ways in which C and D are both selected is $\mathrm{C}_{5}^{3}=10$. Therefore, the number of ways that meet the requirements is $(35-5)+(21-10)=41$.