I started with proving f is one to one.
I considered $(a_{1},b_{1}), (a_{2},b_{2}) \in A \times B$ such that $a_{1}=a_{2}$ and $b_{1}=b_{2}$.
I have to prove $(a_{1},b_{1})=(a_{2},b_{2})$. I am given that $f(a_{1},b_{1})=f(a_{2},b_{2})$. This implies that $(b_{1},a_{1})=(b_{2},a_{2})$. But $(b_{1},a_{1})= (a_{1},b_{1})$ iff $a_{1}=b_{1}$. How to conclude $a_{1}=b_{1}$?
Thanks in advance...!!!