4. Cells of an infinite grid paper are painted in $k$ colors (each cell is painted entirely in one color). What is the largest $k$ such that in every grid rectangle with sides 3 and 4, cells of all these colors will be found?
Answer: 10.

Solution. Divide the infinite grid paper into ten-cell figures as shown in the figure.

![](https://cdn.mathpix.com/cropped/2024_05_06_e625da83596ec69a1f66g-03.jpg?height=408&width=457&top_left_y=1161&top_left_x=845)

The required coloring with 10 colors can be achieved by coloring one such figure in 10 colors and coloring the rest in exactly the same way.

It is obvious that the sheet cannot be painted in more than 12 colors in the required manner. Suppose there is a coloring in 11 or 12 colors. Assume that there is a coloring in 11 colors such that in each $3 \times 3$ square all colors are different. Consider one such square. In the containing $3 \times 4$ rectangle, there are only 11 different colors. Therefore, in the additional $3 \times 1$ strip, some two colors coincide. Then, in the $3 \times 3$ square containing this strip, some two colors coincide.

![](https://cdn.mathpix.com/cropped/2024_05_06_e625da83596ec69a1f66g-03.jpg?height=155&width=149&top_left_y=1987&top_left_x=999)

Suppose we have a coloring in $n$ colors, where $n$ is 11 or 12. Choose a $3 \times 3$ square in which there are no more than $n-3$ different colors. Extend it to rectangles $3 \times 4$ and $4 \times 4$ as shown in the figure. Then, in the strips $3 \times 1$ and $1 \times 3$, the same triplets of colors are represented. Cover the cell marked with a cross with a horizontal rectangle $3 \times 4$. Then this rectangle will contain 5 cells from the strips, meaning it has at least two pairs of cells of the same color, so the total number of colors does not exceed 10. Contradiction.