Lexicographically k-th small string
You are asking two questions. The first is an enumeration question, and the second is about generation or encoding/decoding. The enumeration question is a standard combinatorial exercise, which can be solved using exponential generating functions (and algorithmically, using dynamic programming). For example, the number of strings of length $\ell$ in your example is $\ell!$ times the coefficient of $x^\ell$ in the exponential generating function
$$
\left(1 + x + \frac{x^2}{2!}\right)
\left(1 + x + \frac{x^2}{2!} + \frac{x^3}{3!}\right)^2
\left(1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!}\right).
$$

For the generation problem, the idea is as follows. Suppose that we want the $k$th lexciographically smallest string of length $\ell$. We will uncover the letters one by one. To find the first letter, we count how many strings of length $\ell$ start with each letter&mdash;an instance of the enumeration problem mentioned above&mdash;and use this information to determine the first letter. We find the subsequent letters in a very similar way.