I have two sets of whole numbers $\{s_1,s_2,s_3, \dotsc,s_n \}$ and $\{p_1,p_2,p_3, \dotsc, p_m\}$. Now I will take a number from first set, and XOR it with some number from set 2, and I want to find the sum of all the possible combinations.
For example, if $s_1=\{1,2,3\}$ and $s_2=\{2,1\}$:
the sum would be: $1 \wedge 2 + 1\wedge 1 + 2\wedge 2 + 2\wedge 1 + 3\wedge 2 + 3\wedge 1$, ('+' is regular addition and not binary OR) $= 3+0+0+3+1+2=9$.
EDIT: I can obviously do it using brute force, i.e. find the XOR of each pair first and add them, but is there an efficient way?