First we need to count all the possible ways they can arranged. Let's assume that the order of people in a same group does not matter. Now, the number of ways they can be arranged are 12 choose 3 times 9 choose 4 and the rest is determined.
Now, we count all the ways they can be put in a group.
Case 1: they are put in $g_1$.
We are left to choose 1 from the 10 people to form $g_1$. And 9 choose 4 for the second group and the last group is determined.
Case 2:they are put in $g_2$.
Similarly, we have 10 choose 2 times 8 choose 3 times and $g_3$ is determined.
Case 3: they are put in $g_3$.
I bet you already know how to calculate this. 10 choose 3 times 7 choose 3 and $g_2$ is determined.
Adding all the cases up, and divide by the number of all possible cases. We obtain the probability.