Cat and Mouse

Alice controls the mouse and Bob controls the cat on an undirected graph with n nodes numbered from 0 to n-1. Node 0 is the hole (the mouse's safe house). Initially, the mouse is at node 1 and the cat is at node 2. Alice moves first. On each turn, a player must move their piece along an edge to an adjacent node. The cat may never move into node 0. The mouse wins by reaching node 0. The cat wins by occupying the same node as the mouse. If neither side can force a win, the game continues forever and the result is a draw. Both play optimally.

Return 1 if the mouse can force a win, 2 if the cat can force a win, and 0 if optimal play ends in a draw. The player whose turn it is must be part of the state, because the same positions with different turns can have different results.

Examples
Input: [[1],[0,2],[1]]
Output: 1
Hints

Cat and Mouse

Alice controls the mouse and Bob controls the cat on an undirected graph with n nodes numbered from 0 to n-1. Node 0 is the hole (the mouse's safe house). Initially, the mouse is at node 1 and the cat is at node 2. Alice moves first. On each turn, a player must move their piece along an edge to an adjacent node. The cat may never move into node 0. The mouse wins by reaching node 0. The cat wins by occupying the same node as the mouse. If neither side can force a win, the game continues forever and the result is a draw. Both play optimally.