Consider arrangements of the $9$ numbers $1,2,3,\ldots,9$ in a $3\times3$ array. For each such arrangement, let $a_1$, $a_2$, and $a_3$ be the medians of the numbers in rows $1$, $2$, and $3$, respectively, and let $m$ be the median of $\{a_1,a_2,a_3\}$. Let $Q$ be the number of arrangements for which $m=5$. Find the remainder when $Q$ is divided by $1000$.