Question
Implement a two-player game on a `rows x cols` board. A player wins by placing `k` consecutive marks horizontally, vertically, or along either diagonal.
```python
class TicTacToe:
def __init__(self, rows: int, cols: int, k: int): ...
def move(self, i: int, j: int) -> int: ...
```
## Requirements
- Player `1` moves first and players alternate.
- `move` places the current player's mark and returns that player number if the move completes a run of length `k`; otherwise return `0`.
- After a win, later calls return the existing winner without changing it.
- Initially assume coordinates are valid and empty; explain how production code would reject invalid moves.
- Support rectangular boards and `k` smaller than either dimension.
- Avoid scanning the entire board after every move.
Assume positive integer dimensions and `k`; `k=1` wins on the first move, while a run longer than all board dimensions is unreachable. Winning runs may be at least `k` long. Before a win, coordinates are valid and empty. After a win, any further move returns the stored winner without reading or mutating the supplied coordinates. Do not print the board during ordinary moves. A filled board without a winner returns `0`; draw reporting is outside this interface. Underscored helpers are optional implementation details, not additional assessed functions.
## Design discussion (not graded)
1. Validate illegal moves and report draws.
2. Support undo and replay.
3. Generalize to more players or higher-dimensional boards.
4. Design for a sparse board with very large dimensions.