The weights of the two piles of coal are equal. Now 24 tons of coal are removed from pile A, and 8 tons are brought into pile B. At this time, the weight of coal in pile B is three times that of pile A. How many tons of coal are there in each of the two piles?
两堆煤重量相等，现从甲堆运走24吨煤，乙堆又运入8吨，这时乙堆煤的重量是甲堆的3倍，问两堆煤原来各有多少吨煤？
<gadget id="calculator">24 + 8</gadget>
<output>32</output>

<gadget id="calculator">3 - 1</gadget>
<output>2</output>

<gadget id="calculator">32 / 2</gadget>
<output>16</output>

<gadget id="calculator">16 + 24</gadget>
<output>40</output>

<result>40</result>