Example 1

Example 2

2 <= n <= 1000 <= grid[i][j] <= 1It is guaranteed that the snake starts at empty cells.Example 1

Example 2

2 <= n <= 1000 <= grid[i][j] <= 1It is guaranteed that the snake starts at empty cells.