3. In a $9 \times 9$ grid, there are 81 small squares. In each small square, write a number. If in every row and every column, there are at most three different numbers, it can be guaranteed that there is a number in the grid that appears at least $n$ times in some row and at least $n$ times in some column. What is the maximum value of $n$? Prove your conclusion.

In a $9 \times 9$ grid, there are 81 small squares. In each small square, write a number. If in every row and every column, there are at most three different numbers, it can be guaranteed that there is a number in the grid that appears at least $n$ times in some row and at least $n$ times in some column. What is the maximum value of $n$? Prove your conclusion.