Students are in a classroom with $n$ rows. In each row, there are $m$ tables. It is given that $m, n \geq 3$. At each table, there is exactly one student. We call the neighbors of a student those sitting one place to the right, left, in front, and behind him. Each student shook hands with his neighbors. In the end, there were $252$ handshakes. How many students were in the classroom?

Let's think step by step and output the final answer within \boxed{}.
user