Given a set $S_1$ of m characters and another set $S_2$ of $r$ pairs of characters. Each pairs have different characters and characters in those pairs are essentially from set $S_1$. Make string of length n such that at least one pair from $S_2$ must occur in string and repetition of characters are allowed. Now I have to count number of such strings.
Example: for $m=5, r=3, n=6$.
$S_1={a,b,c,d,e}$ $S_2={(a,c),(b,d),(d,e)}$. Possible strings are $"aaccaa", "aaadeb", "acbdde", "cadbed" "dddbed"$, Following strings are not possible $"aaaaaa", "aabbaa",abeeba$ as these strings does not have both characters from any pairs of $S_2$