$N$ students are seated at desks in an $m \times  n$ array, where $m, n \ge  3$. Each student shakes hands with the students who are adjacent horizontally, vertically or diagonally. If there are $1020 $handshakes, what is $N$?