How many functions are there from a set with $m$ elements to a set with $n$ elements? Counting Functions

How many functions are there from a set with $m$ elements to a set with $n$ elements?

Why is it $n^m$? I think it should be one function.
Please explain.
 A: Hint: Let $A$ be the set with $m$ elements. It's nice to name each element, so lets say $A=\{a_1,\dots,a_m\}$. Let $B$ be the set with $n$ elements $B=\{b_1,\dots,b_n\}$.
A function $f:A\to B$ must map each element of the domain $A$, to some element in $B$. One such function could map every element of $A$ to $b_1$. $f(a)=b_1, \forall a\in A$. Another may map them all to $b_2$. With these functions we have $n$ functions already.
More or less you need to choose the $m$ pairings from $A$ to $B$. I.e. you need to make a choice of $(a_i,b_j)$ for $i\in \{1,\dots,m\}$ and $j\in \{1,\dots,n\}$.

Example:
Say $m=2,n=3$. Then we have $A=\{a_1,a_2\}, B=\{b_1,b_2,b_3\}$.
$$f_1(a_1)=b_1, f_1(a_2)=b_1$$
$$f_2(a_1)=b_1, f_2(a_2)=b_2$$
$$f_3(a_1)=b_1, f_3(a_2)=b_3$$
$$f_4(a_1)=b_2, f_4(a_2)=b_1$$
$$f_5(a_1)=b_2, f_5(a_2)=b_2$$
$$f_6(a_1)=b_2, f_6(a_2)=b_3$$
$$f_7(a_1)=b_3, f_7(a_2)=b_1$$
$$f_8(a_1)=b_3, f_8(a_2)=b_2$$
$$f_9(a_1)=b_3, f_9(a_2)=b_3$$
So each row above gives you a function $f_i:A\to B$. The only one-to-one (i.e. injective) functions here are $f_2,f_3,f_4,f_6,f_7,f_8$.
A: If $k=1$ then there are $n$ functions since there are $n$ ways into which one element can be mapped to take one element as value. 
If $k=2$ then there are $n \cdot n=n^2$ pairs that two variables can take. To see this, there are $n$ pairs of the form $(a_1,b_i) ;i=1,2,,,n$, and then $n$ pairs of the form $(a_2,b_i);i=1,2,...,n$, and so on, until we arrive at $n$ pairs of the form $(a_n,b_i);i=1,2,...,n$, so $n \cdot n=n^2$ in total.
...
If $k=m$ then there are $n \cdot n \cdot ... \cdot n=n^m$ ($n$ multiplied $m-1$ times) $m$-tuples that $m$ variables can take.
A: 

Imagine that the input has 5 elements and the output has 3 elements. That means for each one of the 5 elements, we have three available options. So generally speaking, that means if we have m elements of input and n elements of output, that means for each of the m elements, we have n choices.
You can imagine something like this.

Because each of the m inputs has n choices, we can say through the multiplication rule, that the total number of functions is $n^m$.
