How many functions from $f:A \rightarrow B$ where $A=\{a_1,a_2,\ldots,a_6 \}, B=\{1,2,3,\ldots,9 \}$ such that $f(a_{i+1})>f(a_{i}) \quad \forall \quad 1 \leq i \leq 5$ and $f(a_j) \neq j \quad \forall 1 \leq j \leq 6$
Attempt: $a_6$ can take values $7,8,9$. $a_5$ can take values $6,7,8$ so on till $a_1$ can take values $2,3,4$. I wrote down these possibilities in a vertical column, one below the other, in the same order. I noted that starting from any row, we can proceed(values permissible) only vertically upward or diagonally upward to the next row.
I couldn't think of any other idea. Although here brute Force with the above logic is feasible since the numbers and possibilities are fairly small (I got the answer doing so), but is there any other way? Preferably a more general one with set A having $n$ elements and set B having $m$ elements with the same constraints.
I couldn't spot a pattern in the above brute Force method.