Little Mate got an array of lowercase letters from the English alphabet as a present from his
parents. In order to have at least some use of such a clever present, he decided to use it for
finding rhymes when writing his next song.
To find a specific rhyme, Mate wants to select a word of length D that ends with an array of
characters XY, i.e. where the next to last letter is X, and the last Y. Mate’s process of
selecting a word is by first crossing out some letters in a given sequence, and then merging
the letters he didn’t cross out into a single word. He wants to know in how many different
ways he can cross out the letters so that he meets the given conditions.
The selection of two words is considered distinct if the sets of positions of the crossed-out
letters are different.