The sum of the m numbers divided by m (which is the average) equals n^2. Then, the sum of the m numbers equals mn^2. The sum of the n numbers divided by n (which is the average) equals m^2. Then, the sum of the n numbers equals nm^2. The average of m+n numbers which is the sum of the m numbers plus the sum of the n numbers divided by (m+n) equals (mn^2+nm^2)/(m+n). This is mn(n+m)/(m+n). Then the factor (m+n) can be ruled out and the result is mn.
Independent variables must be the amount of cans you buy of cat food. The dependent variable, well that must be the cost. Depending on how many cans you buy, the cost changes! :)