We can deal with the first restriction by considering A and B as a single person, but with two different versions (AB and BA), thus with just that restriction it would be 2 * 9!.

For the second restriction you can think similarly and start with all permutations, then subtract out those that have C and D next to each other. Can you complete it?