A bijection between $Hom(S,T)$ and $Hom(K^T,K^S)$ The following question is the continuation of this question. 
Let $K$ be a field, $S$ and $T$ be finite sets and let $Hom(S,T)$ denote the set of functions $f: S \to T$. For $\sigma \in Hom(S,T)$, let $\sigma^*: K^T \to K^S$ be given by $\sigma^*(g)(s) = g(\sigma(s))$ for all $s \in S$ and $g \in K^T$. Show that the map $F:Hom(S,T) \to Hom_{K-alg}(K^T,K^S)$ is a bijection.
I think I could show that $F$ is injective: suppose $F(\sigma)=F(\sigma')$, or $g(\sigma(s)) = g(\sigma'(s))$ for all $g \in K^T, s \in S$, then we must have $\sigma(s) = \sigma'(s)$ for all $s \in S$, which in turn implies $\sigma = \sigma'$. But how do I find the preimage of a $K$-algebra homomorphism $ K^T \to K^S$?
 A: Let $t, s$ be the number of elements in $T, S$.  We can identify the $K$-algebra $K^T$ with $\prod\limits_{i=1}^t K$, with addition and multiplication defined componentwise.  Similarly we can identify $K^S$ with $\prod\limits_{i=1}^s K$.  Let $v_1, ... , v_t$ be the standard basis for $K^T$, and $w_1, ... , w_s$ the standard basis for $K^S$.  Note that $v_iv_j = \delta_{ij} = w_i w_j$.  Any function $\sigma$ from $S$ to $T$ we can think of as a function from $\{1, 2, ... , s\}$ to $\{1, 2, ... , t\}$.  With the notation I've introduced, we have that for a given $\sigma: S \rightarrow T$, the associated $K$-algebra homomorphism $\sigma^{\ast}: K^T \rightarrow K^S$ is defined by the formula $$\sigma^{\ast}(c_1v_1 + \cdots + c_nv_n) = c_{\sigma(1)}w_1 + \cdots + c_{\sigma(s)}w_s$$
Now let $f: K^T \rightarrow K^S$ by any $K$-algebra homomorphism.  We want to show that $f = \sigma^{\ast}$ for some $\sigma: S \rightarrow T$.  We know $f$ satisfies four properties:

(i) $f$ preserves addition.
(ii) $f$ preserves scalar multiplication.
(iii) $f$ preserves multiplication.
(iv) $f$ sends the multiplicative identity of $K^T$ to the identity of $K^S$.  In other words, $f(v_1 + \cdots + v_t) = w_1 + \cdots + w_s$.

The trick to this problem is exploiting these properties.  Since $f$ is $K$-linear, it is completely determined by its effect on $v_1, ... , v_t$.  For each $j$, we have $$f(v_j) = c_1w_1 + \cdots + c_sw_s$$ for some $c_i \in K$.  But since $v_j = v_j^2$, and $f$ preserves multiplication, $$c_1w_1 + \cdots + c_sw_s = f(v_j) = f(v_j)^2 = c_1^2 w_1 + \cdots + c_s^2 w_s^2$$ hence $c_i = c_i^2$ for all $i$.  This implies each $c_i$ is $0$ or $1$.
So, each $f(v_j)$ is sent to a sum of finitely many $w_i$s, possibly none at all.  Also for $i \neq j$, no $w_k$ can occur in both the sum of $f(v_i)$ and $f(v_j)$.  For example, if it were the case that $f(v_1) = w_1 + w_2$, and $f(v_2) = w_2 + w_3$, then we would have $0 = f(v_1v_2) = f(v_1)f(v_2) = w_2$, absurd.  At the same time, every $w_k$ occurs in the sum of $f(v_i)$ for some $i$.  This is on account of property (iv).
Given $k \in S$, we have shown that there is a unique $i \in T$ such that $f(v_i)$ is a sum of standard basis elements in $K^S$ with $w_k$ appearing in that sum.  So we define $\sigma(k) = i$, and this is a well defined function from $S$ to $T$.  Thus for all $i \in T$, $$f(v_i) = \sum\limits_{k \in \sigma^{-1}\{i\}} w_k$$ and hence $$f(c_1v_1 + \cdots + c_tv_t) = \sum\limits_{i=1}^t c_i \sum\limits_{k \in \sigma^{-1}\{i\}} w_k = \sum\limits_{k=1}^s c_{\sigma(k)}w_k = \sigma^{\ast}(c_1v_1 + \cdots + c_tv_t)$$
