S: the set of numbers said by player 1;
P: the set of numbers said by player 2;
S^2 * P = a;
S * P^2 = b;
a * b = (S * P)^3, so a * b must be a perfect cubic number. Binary search to check this.
Let X be the cubic root of a * b, X = S * P.
In order to have a valid S and P, then a must be divisible by X and b must be divisible by X.