Alice and Bob play a game of Tic-Tac-Toe on a grid of size $N \times M$. The rules of this game are the same as the original Tic-Tac-Toe:
- Alice plays first (white); Bob plays second (black).
- On each player's turn, they put a piece of their own on an empty cell on the grid.
- When a player's pieces form a three-in-a-row (horizontally, vertically, or diagonally in either 45-degree direction), the player wins.
- If no one wins until the entire board is filled up with pieces, the game ends in a draw.
Instead of trying to win, Alice and Bob decided to cooperate towards a draw. How many distinct drawn endgames are possible when $N, M \ge 4$? Two endgames are distinct if the pieces on at least one cell is different. The order in which each piece is placed is not considered.
For example, $3 \times 3$ grid has 16 distinct drawn endgames:
When one side of the grid is 3, the answer is given as OEIS A339631.