8. Fill the four characters “马” “上” “成” “功” in a $5 \times 5$ grid, with at most one character in each small square. “马” “上” must be filled in from left to right, and “成” “功” must also be filled in from left to right. “马” “上” must be in the same row or in the same column from top to bottom, or “成” “功” must be in the same row or in the same column from top to bottom. The number of different ways to fill the grid is $\qquad$ (answer with a number).
8.42100.

The problem is equivalent to:
Filling 2 $a$s and 2 $b$s in a $5 \times 5$ grid, with at most one letter in each small square, such that at least one pair of the same letters is in the same row or column.
First, consider the case where the same letters are neither in the same row nor in the same column.
The number of ways to place 2 $a$s such that they are neither in the same row nor in the same column is $\mathrm{C}_{5}^{2} \mathrm{~A}_{5}^{2} = 200$. Similarly, the number of ways to place 2 $b$s such that they are neither in the same row nor in the same column is also $\mathrm{C}_{5}^{2} \mathrm{~A}_{5}^{2} = 200$.
When both conditions are satisfied, there are two scenarios that do not meet the requirement:
(1) The 2 $a$s are in the same squares as the 2 $b$s, which has 200 ways;
(2) One of the 2 $a$s is in the same square as one of the 2 $b$s, which has $\mathrm{C}_{25}^{1} \mathrm{~A}_{16}^{2} = 25 \times 240 = 6000$ ways.

Therefore, the number of ways where the same letters are neither in the same row nor in the same column is $40000 - 200 - 6000 = 33800$.
Thus, the number of ways that meet the problem's conditions is
$$
\frac{A_{25}^{4}}{2! \times 2!} - 33800 = 75900 - 33800 = 42100 \text{. }
$$