314 black balls, 4 white balls and 2 red balls are arranged in a row. Find the total number of ways this can be done if all the balls of the same colour do not appear in a consecutive block.
31. Answer: 2376
Using the Principle of Inclusion and Exclusion, number of ways $=\frac{10!}{4!4!2!}-2 \frac{7!}{4!2!}$ $-\frac{9!}{4!4!}+2 \frac{6!}{4!}+\frac{4!}{2!}-3!=3150-210-630+60+12-6=2376$.