Problem

Source: Bosnia and Herzegovina JBMO TST 2018

Tags: combinatorics, counting



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