P309: Enumeration of all $k$-ary strings of length $n$ that have no substring equal to $f$

P309: Enumeration of all $k$-ary strings of length $n$ that have no substring equal to $f$
Input:
A $k$-ary string $f$ with length $m$, and a positive integer $n$.
Output:
All $k$-ary strings of length $n$ that have no substring equal to $f$.
Complexity:
$O(1)$ time per string.
Comment:
Reference:
[Ruskey2000a] (Bibtex)