# Combinatorics - problem with Inclusion–exclusion principle

I have a little mathematic problem. I have bar code with 3 types of black (x, y, z) lines and 2 types of white lines (w, v). There are 12 black lines and 11 white lines. And black and white lines alternate like B, W, B, W, B.. 2 black lines are outside.

Now should I find how many codes I can make from it when every type of line will be used minimaly ones. It means that I will have minimally one x, minimally one y, minimally one z, minimally one w and minimally one v.

For calculation I used Inclusion–exclusion principle. So I find how many black sequence don´t have minimally one from every type and how many sequence don´t have minimaly one from white type.

The numbers:

exists 3^12 possibilites how get black sequence without any condition

exists 2^11 possibilites how get white sequence without any condition

exists 12 285 possibilites when minimally one type of black is missing

exists 2 possibilites when minimally one type of white is missing

now comes the problem. The number of codes I can get when I multyply the 3^12 * 2^11 and subtract (12 285 * 2)? (the result = 1 088 366 598)

(3^12 * 2^11) - (12 285 * 2) = 1 088 366 598

Or should I sooner substract the numbers for black sequence 3^12 - 12 285 and then multyply it with white sequence (2^11 - 2)? (result = 1 062 193 176)

(3^12 - 12 285) * (2^11 - 2) = 1 062 193 176

Which method is correct and why?

$$\left(3^{12}-3 \times 2^{12} +3\times 1^{12} -0^{12}\right)\left(2^{11}-2 \times 1^{11} +0^{11}\right)$$
which, as you have calculated, is $1062193176$.