The three bags of candies

The three bags of candies

Let's say I have 48 candies spread in 3 bags. If from the first bag I pass to the second as many candies as there are in the third and then I pass 6 candies from the second to the first, and finally, I pass 4 candies from the second bag to the third, the result is that I now have the same amount of candies in all three bags.

How many candies did he initially have in each bag?


If we do all the operations in reverse, knowing that finally each bag will have 16 candies, we will realize that:
The 1st bag initially had 22 candies, the 2nd bag had 14 candies and the 3rd bag had 12 candies.