Construction of the "swap map" via universal property for products in $Set$ Lemma (Universal Property for Products) let $X,Y$ be sets and let $A$ be a set along with functions $f:A\rightarrow{X}$ and $g:A\rightarrow{Y}$ then there exists a unique function $\phi:A\rightarrow{X\times{Y}}$ which is defined by $\phi(a)=(f(a),g(a))$ for all $a\in{A}$. Define the swap map $S:X\times{Y}\rightarrow{Y\times{X}}$ by $S(x,y)\mapsto{(y,x)}$, I am interested in how to construct $S$ by using the above lemma (UPP). 
My attempt: since $\phi:A\rightarrow{X\times{Y}}$ and $S:X\times{Y}\rightarrow{Y\times{X}}$ we have the composition $S\circ\phi:A\rightarrow{Y\times{X}}$ defined by $(S\circ\phi)(a)=S(f(a),g(a))=(g(a),f(a))$ , this is where I have hit a wall, I know how $S$ is defined but I am unsure of how to construct it from the above lemma, although I have a strong feeling I need to use the natural projections $\pi_{X}:X\times{Y}\rightarrow{X}$ and $\pi_{Y}:X\times{Y}\rightarrow{Y}$. Any hints would be much appreciated.
 A: If you want to write a map $S : X \times Y \to Y \times X$, you could use the UPP for $Y$ and $X$: given two morphsims $f : A \to Y$ and $g : A \to X$, there exists an unique morphism $h = \langle f , g \rangle : A \to Y \times X$ such that $\pi_Y \circ h = f$ and $\pi_X \circ h = g$. To find $S$ just take $A = X \times Y$, $f = \pi_Y$ and $g = \pi_X$, and then $S = h$.
A: The set $X\times Y$ together with the projection $\pi_X:X\times Y\to X$ and $\pi_Y:X\times Y\to Y$ serves as the categorical product in the category of sets, that means, given a set $A$ and maps $f:A\to X$ and $g:A\to Y$, there is a unique map $\phi=(f,g)^\flat:A\to X\times Y$ such that $\pi_X\phi=f$ and $\pi_Y\phi=g$. It's clear that this map must be $\phi(a)=(f(a),g(a))$.
The set $Y\times X$ with its projections to $p_X$ and $p_Y$ is another product object for the pair $(X,Y)$ of sets, that means it satisfies the same universal property. Taking the maps $f,g$ to be $\pi_X$ and $p_Y$, it follows there is a unique map $s:X\times Y\to Y\times X$ such that $\pi_X=p_Xs$ and $\pi_Y=p_Ys$. On the other hand, there is a unique map $t:Y\times X\to X\times Y$ such that $\pi_Xt=p_X$ and $\pi_Yt=p_Y$. Since $\pi_Xts=\pi_X$ and $\pi_Yts=\pi_Y$, and the identity map on $X\times Y$ has the same composition with the projections as $ts$, it follows by uniqueness that $ts=1$ and similarly that $st=1$. This actually shows that any two product objects for $(X,Y)$ are isomorphic. In $\mathbf{Set}$, $s$ is just $(x,y)\mapsto(y,x)$.
On the other hand, one could regard $Y\times X$ as the canonical product object for $(Y,X)$. If you wanted a functor $\mathbf{Set}\times\mathbf{Set}\to\mathbf{Set}$, sending each pair $(X,Y)$ of sets to a product, you would probably take the one using the first coordinate as the first factor and the second coordinate as the second factor, thus $(Y,X)\mapsto Y\times X$ (and $(g:Y\to Y',f:X\to X')\mapsto g\times f:Y\times X\to Y'\times X'$). Then again, we also have the functor $(X,Y)\mapsto Y\times X$, taking the first entry as the second factor. Note that $s(f\times g)=(g\times f)s:X\times Y\to Y'\times X'$, so the swapping maps $s$ form a natural transformation between both functors.
