Let's assume that X people participated in the math group but did not participate in the painting group (that is, only participated in the math group), and Y people participated in the painting group but did not participate in the math group (that is, only participated in the painting group alone);
X+3=2(y+3)- 12。
X+y+3=60-30=30 (this kind of topic can actually be drawn by yourself to understand the relationship),
X = 15 and Y = 12 can be solved (note their meanings).
So there are 15+3= 18 people in the math group and 12+3= 15 people in the painting group.