I'm out at the moment, so I'll explain asap.
There are 8C3 * 31C3 ways in selecting 3 teachers and 3 students.
Since order doesn't matter, we use combinatoric, nCr, instead of permutation, nPr.
Now, we merely need to select 3 teachers from 8 teachers (objects) and 31 students (objects).
Since, we want them simultaneously, we need to multiply the two together.
In essence, there are 8C3 × 31C3 ways