Consider arrangements of the 9 numbers 1,2,3, \ldots, 9 in a 3 \times 3 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 then let m be the median of \left\{a_{1}, a_{2}, a_{3}\right\}. Let Q be the number of arrangements for which m=5. Find the remainder when Q is divided by 1000 .