How many strings of length 5 of the letters A, B, C, D, and E contain exactly one A and exactly one D if repetition of letters is allowed?
We must have exactly 1 A and exactly 1 B the other 3 letters can be C,D,E repeats allowed, so that is 3^3=27 ways with order counting.
The other A and B must be slotted into the string. 5C2=10 places but either the A or B can go first so that is 20 places.
So I get 27*20 = 540 ways.