2. (16 points) In a school, the ratio of male to female students in the first year of junior high school is $8: 7$. After one year, 40 new students are transferred in, and the ratio of male to female students becomes 17:15. By the third year of junior high school, some students have transferred out, and some new students have transferred in, resulting in a net increase of 10 students. At this point, the ratio of male to female students is 7:6. How many male and female students were admitted in the first year of junior high school?
Note: The number of first-year junior high school students admitted does not exceed 1000.
2. Let the total number of new students in Grade 7 be $15 a$ people, the total number of students in Grade 8 be $32 b$ people, and the total number of students in Grade 9 be $13 c$ people, where $a$, $b$, and $c$ are integers. From the problem, we have
$$
\left\{\begin{array}{l}
15 a+40=32 b, \\
15 a+50=13 c .
\end{array}\right.
$$
Subtracting (1) from (2) gives $c=\frac{2(16 b+5)}{13}$, so $(16 b+5)$ is a multiple of 13. Let $16 b=13 k+8$, i.e.,
$$
8(2 b-1)=13 k \text {. }
$$

Thus, $k$ is a multiple of 8, and an odd multiple.
When $k=8 \times 1$, $b=7$ substituting into (1) gives
$$
32 \times 7-40=184,15 \times 184 ;
$$

When $k=8 \times 3$, $b=20$ substituting into (1) gives
$$
32 \times 20-40=600,15 \times 600 \text {; }
$$

When $k=8 \times 5$, $b=33$ substituting into (1) gives
$$
32 \times 33-40=1016>1000 \text {, and } 15 \nmid 1016 \text {. }
$$

In summary, the school admits 600 new students in Grade 7, of which $600 \times \frac{8}{15}=320$ are boys, and 280 are girls.