Given:
A×B= {(a,x),(a,y),(b,x),(b,y)}
Compare A×B and {(a,x),(a,y),(b,x),(b,y)}
We know that the cartesian product of two non-empty sets P and Q is given by : P×Q= {(p,q):p ϵ P,q ϵ Q}
Hence, A is set of all first elements and B is the set of all second elements.
A= {a,b}, B= {x,y}