TITLE: Minimal number of "words" that contain all possible pairs of letters in all position pairs
QUESTION [7 upvotes]: Defining a word as sequence of ordered letters ($1$..$q$ letters) of length L, 
what is the minimal number of words such that among the entire list of words,
at every pair of positions, I can find any two letters?
for example, for $q=3$ and $L=2$
here is the minimal list:
$$1 1,
2 2,
3 3,
1 2,
2 3,
3 1,
1 3,
2 1,
3 2,$$
total $q^2$ words are needed.
but for $L=3$ the minimal number is still $q^2$, obtained by:
$$1 1 1,
2 2 1,
3 3 1,
1 2 2,
2 3 2,
3 1 2,
1 3 3,
2 1 3,
3 2 3,$$
for $L=4$ the number is different...
what is the minimal number of words for $(q,L)$ and specifically, what is the asymptotic value for $L\gg 1$?
Thanks for you answers!

REPLY [2 votes]: First, let me elaborate the upper bound from @kodlu’s answer. If $q$ is a power of a prime, then $q^2$ words suffice for $L=q+1$ (for $L=q$ it is almost trivial, improving by $1$ needs just a bit more). Then, doubling $L$ increases the number of words by $q(q-1)$, so for those values of $L$ it suffices to take $q(q-1)\log_2\frac L{q+1}+q^2$ words.
Let me show a somewhat close lower bound. Let $w$ be the number of words; set $k=w-q(q-1)+1$. Take any $k$ words. Let $v_i$ be a vector composed from all $i$th entries of the $k$ words. If two of those vectors, say $v_i$ and $v_j$, coincide, this means that at most $w-k=q(q-1)-1$ words differ in positions $i$ and $j$, so not all pairs are covered.
Thus, we have $L$ distinct vectors in $[q]^k$, so $L\leq q^k$, or $w\geq q(q-1)+1+\log_qL$.
Therefore, the growth rate is indeed logarithmic (but the constant at the logarithm is yet unclear).
Addendum. Let me present an example for $L=q+1$, when $q$ is a power of a prime.
Consider an affine plane $\mathbb F_q^2$. All lines in it are partitioned into $q+1$ classes $C_1,\dots,C_{q+1}$ of mutually parallel lines (one class consists of all lines with equations of the form $ax+by=c$ with fixed $(a:b)$). Enumerate the lines in each class by numbers from 1 to $q$.
For each point $p\in \mathbb F_q^2$, take a word $w_1\dots w_{q+1}$ where $w_i$ is the number of the line in $C_i$ passing through $p$. Then, for any two classes $C_i$ and $C_j$ and for any two lines in them, the lines meet at a unique point, which means exactly what we need to get in the $i$th and $j$th positions.