Solution (source code)

= Solution

Let $(e_{r,a},e_{r,b})_{r=1}^L$ be the standard orthonormal basis of $\mathbb R^{2L}$ and define
$$
\phi(x)=\sum_{r=1}^Le_{r,x_r}.
$$
Then
$$
\langle\phi(x),\phi(y)\rangle
=\sum_{r=1}^L\mathbf1_{\{x_r=y_r\}}=g(x,y).
$$
Thus $g$ is a <positive-semidefinite kernel>.