First, line up the sophmores in any way. Next, line up the juniors across from the sophmores in any one of $n!$ ways. After that, line up the seniors across from the juniors in any one of $n!$ ways. The result is a total of $(n!)^2$ ways.
First, line up the sophmores in any way. Next, line up the juniors across from the sophmores in any one of $n!$ ways. After that, line up the seniors across from the juniors in any one of $n!$ ways. The result is a total of $(n!)^2$ ways.