5. (12 points) As shown in the figure, in a $7 \times 7$ grid, each cell is filled with a number such that cells with the same number are connected (two connected cells must share a common edge). Now, two each of the numbers 1, 2, 3, 4, and 5 are already given. Therefore, the sum of all the numbers in the grid is $\qquad$
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline 1 & & & & & & 2 \\
\hline 5 & 3 & & & 3 & 4 & \\
\hline & & & 2 & & & \\
\hline & & & & & & \\
\hline & & & & 1 & & \\
\hline & & 5 & & & & \\
\hline 4 & & & & & \\
\hline
\end{tabular}
【Solution】Solution: First, understand the problem, find the unique blank cell to fill, for example, the first 1 in the first row, the only adjacent blank cell must be 1, and so on, the first 5 in the second row also has a unique adjacent cell. Work backwards to derive the unique pattern. The sum is 150.
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline 1 & 1 & 1 & 2 & 2 & 2 & 2 \\
\hline 5 & 3 & 1 & 2 & 3 & 4 & 4 \\
\hline 5 & 3 & 1 & 2 & 3 & 3 & 4 \\
\hline 5 & 3 & 1 & 1 & 1 & 3 & 4 \\
\hline 5 & 3 & 3 & 3 & 1 & 3 & 4 \\
\hline 5 & 5 & 5 & 3 & 3 & 3 & 4 \\
\hline 4 & 4 & 4 & 4 & 4 & 4 \\
\hline
\end{tabular}

Therefore, the answer is 150.