Some $ m$ squares on the chessboard are marked. If among four squares at the intersection of some two rows and two columns three squares are marked then it is allowed to mark the fourth square. Find the smallest $ m$ for which it is possible to mark all squares after several such operations.
To solve this problem, we need to determine the smallest number \( m \) of initially marked squares on an \( n \times n \) chessboard such that it is possible to mark all squares after several operations. The operation allowed is: if among four squares at the intersection of some two rows and two columns three squares are marked, then the fourth square can be marked.

1. **Initial Assumption**:
   We assume that the initial marking is already given and cannot be changed by us.

2. **Lower Bound**:
   We need to show that \( m > (n-1)^2 \). To see why this is necessary, consider marking all squares in all rows except the last row. In this case, we have marked \( (n-1) \times n = n^2 - n \) squares. This is less than \( (n-1)^2 \), and we cannot mark the entire board because the last row remains unmarked.

3. **Upper Bound**:
   We need to show that \( m = (n-1)^2 + 1 \) is sufficient to guarantee that all squares can be marked. 

4. **Proof**:
   - Consider any unmarked square \( a \). Since there are at most \( (n-2) \) unmarked squares left in the same column as \( a \), there is at least one marked square in that column. Call this marked square \( b \).
   - Now consider all other \( (n-1) \) columns. In each of these columns, search for squares \( c \) and \( d \) such that \( c \) and \( d \) are in the same rows corresponding to \( a \) and \( b \), respectively.
   - Since there are \( (n-1) \) columns and at most \( (n-2) \) unmarked squares in each column, there must be at least one column where both \( c \) and \( d \) are marked.
   - Now consider the square formed by \( a, b, c, \) and \( d \). Since three of these squares are marked, we can mark the fourth square \( a \).
   - Since \( a \) was arbitrary, we can repeat this process for all unmarked squares.

5. **Conclusion**:
   Therefore, \( m = (n-1)^2 + 1 \) is the minimum number of initially marked squares required to guarantee that all squares can be marked.

The final answer is \( \boxed{ (n-1)^2 + 1 } \)