Find all pairs of positive integers $(n, k)$ for which it is possible to write numbers in the cells of an $n \times n$ chessboard such that the sum of the written numbers is positive, but the sum of the numbers in any $k \times k$ connected submatrix is negative.
Obviously, if $k>n$, the desired filling is possible, since a $k \times k$ subtable does not even exist. Thus, in the following, we can assume that $k \leq n$.

If $k$ is a divisor of $n$ (in particular, if $k=n$), then the $n \times n$ table can be covered by $k \times k$ subtables such that each cell is covered exactly once. If now the sum of the numbers in each $k \times k$ subtable is negative, then the sum in the entire table is also negative, although it should be positive. Thus, in this case, the filling cannot be carried out in accordance with the conditions.

In the remaining case ($k \leq n$, $k$ is not a divisor of $n$), let $n=qk+r$, where $q$ and $r$ are natural numbers, $0<r<k$. We fill the table as follows: in each row, we place $-p$ in the first $r$ columns, and 1 in the remaining $n-r$ columns, where $p$ is a natural number greater than $k-1+r$.

On the one hand, the sum of the numbers in the entire table is

$$
n \cdot (n-r) - p \cdot r > 0
$$

due to the choice of $p$. On the other hand, in any connected $k \times k$ subtable, there is exactly one column with $(-p)$, and 1s in the others, so the sum of the numbers is

$$
k \cdot (k-1) + k \cdot (-p) = k(k-1-p) < 0
$$

This means that this filling satisfies the conditions of the problem.

In summary, the sought pairs $(n, k)$ are exactly those in which $k$ is not a divisor of $n$.