An Optimal Sauer Lemma Over $k$-ary Alphabets