Total no of permutations How do i solve this type of problem:
Suppose i have two sets $s_1 = \{a,b,c\}$ and $s_2 =\{ d,e\}$
now i have $5$ blocks which can be filled using any of theses $\{a,b,c,d,e,f,g,h\}$
Now the question is how many permutation exists such that one elements from set $s_1$ & one element from set $s_2$ exists in any of these 5 blocks..
 A: Try to think about it in the opposite direction(as commented above by Snoopy), count all ways and subtract the ways where there is no block in which one character of $S_1$ and $S_2$ meet.
The total number of configurations is $\underbrace{5*\cdots *5}_{\text{ 8 times}}=5^8$ because you have 5 blocks for each letter.
As there are 3 letters ($\{f,g,h\}$) without any restriction you have $5^3$ possibilities and that, by the multiplication principle, must be multiplied by the ways to put the letters that matter ($S_1\cup S_2$) in the blocks. Let's place the characters in $S_1=\{a,b,c\}$ then there are 3 disjoint ways:
1) Use 1 block to place them.
2) Use 2 blocks to place them.
3) Use 3 blocks to place them.
I am going to do 1, try to do 2 and 3.
If you are going to use $1$ block you must select it from the $5$ blocks, you can do it in $\binom{5}{1}$ ways. Now we must place the elements of $S_2=\{d,e\}$ but you can't use the block you chose, so you are left $4$ blocks, that can be done in $4^2$ ways. So the total ways would be $\binom{5}{1}4^2$.

 So, the solution would be $5^8-5^3(\binom{5}{1}4^2+\binom{5}{2}(2^3-2)*3^2+\binom{5}{3}3!*2^2)$

Hope it helps
