4、The weight ratio of two bags of candy, A and B, is $4: 1$. If 10 grams are taken from bag A and put into bag B, the weight ratio of A and B becomes $7: 8$. Therefore, the total weight of the two bags of candy is $\qquad$ grams.
4. Solution: Let the weight of the first bag of candy be $4 x$ grams, and the weight of the second bag of candy be $x$ grams, then $(4 x-10):(x+10)=7: 8$ Solving for $x$ gives $x=6$, the total weight is $5 x=30$ (grams).