If we transform the handshaking into a graph where the people are vertex and handshakes are represented by edges, we will get one or more disjoint cycles. Each cycle must have at least $3$ people so that everyone shakes hand with two other.
So we have $4$ cases.
- We can take all of the people and put them in a cycle of length $9$.
- We can divide them into $5$-cycle and $4$-cycle.
- We can divide them into $6$-cycle and $3$-cycle.
- We can divide them into three $3$-cycles
For the first case, this is just cyclic permutation and it can be done in $\frac{9!}{2\times9}$ since rotation and reflection results in same handshaking.
For the second case, we can divide $9$ people into group of $5$ people and $4$ people in ${9\choose4}=\frac{9!}{4!\cdot5!}$ ways. For each grouping, there are $\frac{5!}{2\times5}\cdot\frac{4!}{2\times4}$ ways to put them in the cycles. So, by multiplying this two results, we get total $\frac{9!}{2\times4\times2\times5}$ ways
Similarly, for the third case, there are total $\frac{9!}{2\times3\times2\times6}$ ways to do that.
And for the fourth case, there are just $\frac{9!}{2\times3\times2\times3\times2\times3}$ ways similarly.
So, \[N=9!\left(\frac{1}{2\times9}+\frac{1}{2^2\times4\times5}+\frac{1}{2^2\times3\times6}+\frac{1}{2^3\times3\times3\times3}\right)\]
\[\Longrightarrow \boxed{N=31416}\]
Seriously? That's the answer??