2. Given $m, n$ are non-negative integers, set $A=\{1, n\}, B=\{2,4, m\}$, set $C=\{c \mid c=x y, x \in A, y \in B\}$, if $|C|=6, $ the sum of all elements in $C$ is 42, then the value of $m+n$ is $\qquad$ .
From the problem, we know that $(1+n)(2+4+m)=42$. From the distinct elements of the set and $|C|=6$, we know that $n \neq 0,1,2,4$. From $1+n \mid 42$, we know that $n \neq 3$, so $n \geq 5$. Similarly, $m \geq 1$, so $1+n \geq 6, 2+4+m \geq 7$. Since their product is 42, both must be equal, i.e., $m=1, n=5$. At this point, $n+m=6$.