look for the first row:
we pick 8 students from 1st class : 16C8
for next row, we pick 8 students from other class : 16C8
now for next two rows we have 8 students left for each row. so ,there's only one way to select them.
as we can start the row with either of the class's students so we multiply it with 2.
and students can arrange themselves in each row so, we have 4 times 8!.
so, ans : 2*16C8*16C8*8!*8!*8!*8!.
I hope u umderstood.
if any query u can ask me,..