As shown in the figure, $A(1,1,1), B(2,1,1), C(2,2,1), D(1,2,1)$, $E(1,1,2), F(2,1,2), G(2,2,2), H(1,2,2)$, where the first coordinate represents a square or circular block, the second coordinate represents a red or yellow block, and the third coordinate represents a block printed with Nanchang or Beijing.
Obviously, the different ways of taking any point from $A, B, C, D, E, F, G, H$ and walking $n(2 \leqslant n \leqslant 8)$ steps along the edges of the cube $A B C D-E F G H$, is $D_{n}$. Then $D_{2}=8 \times 3=24, D_{3}=8 \times 3 \times 2=48, D_{4}=8 \times 3 \times 2 \times 2=96$, $D_{5}=8 \times 3 \times 2 \times 1 \times 1$ (the first four points are coplanar $)+8 \times 3 \times 2 \times 1 \times 2$ (the first four points are not coplanar $)=144$, $D_{6}=8 \times 3 \times 2 \times 1 \times 1 \times 2$ (the first four points are coplanar) $+8 \times 3 \times 2 \times 1 \times 1 \times 2+8 \times 3 \times 2 \times 1 \times 1 \times 1$ (the first four points are not coplanar $)=240$, $D_{7}=8 \times 3 \times 2 \times 1 \times 1 \times 2 \times 1$ (the first four points are coplanar) $+8 \times 3 \times 2 \times 1 \times 2 \times 1 \times 1$ (the first four points are not coplanar) $=192$, $D_{8}=8 \times 3 \times 2 \times 1 \times 1 \times 2 \times 1 \times 1$ (the first four points are coplanar) $+8 \times 3 \times 2 \times 1 \times 1 \times 1 \times 1 \times 1$ (the first four points are not coplanar $)=144$, so $\max _{2 \leqslant n \leqslant 8} D_{n}=D_{6}=240$.
8. There are 8 different building blocks, each block being either square or circular in shape, red or yellow in color, and printed with the city name Nanchang or Beijing. From the 8 different building blocks, $n$ blocks are taken in sequence $(2 \leqslant n \leqslant 8), D_{n}$ represents the total number of all different ways to take the blocks such that the last one and the previous one taken have exactly two of the three aspects (shape, color, city name) the same. Then $\max _{2 \leqslant n \leqslant 8} D_{n}=$ $\qquad$ .