If two sets A and B are having 39 elements in common, then the number of elements common to each of the sets A×B and B×A are