Alice and Bob are planning to play another game.
There is a Directed Acyclic Graph (DAG) with $n$ vertices (labeled starting from $1$), where each vertex is either black or white. The graph may contain multiple edges, and the outgoing edges for each vertex are ordered.
There is a DFS program with the following pseudocode:
define procedure dfs(u):
if u is a white vertex
traverse all outgoing edges (u,v) of u in order
read a boolean value g
if g
dfs(v)
else
traverse all outgoing edges (u,v) of u in order
dfs(v)
read an integer r
dfs(r)
This program has a special property: it automatically pauses before the start of every dfs procedure call.
Alice and Bob start $k$ such programs, and for each program, they input a vertex label as $r$ (the input $r$ may differ between programs). Now, all these programs are paused after reading $r$ and before calling dfs(r).
Then the game begins. Alice goes first, and the players take turns performing the following operation:
- Choose a program that has not yet finished execution and resume it from its paused state. Continue executing the program until it pauses again or finishes. During this process, every time the program reads $g$, the current player can choose whether the result is
trueorfalse.
Each program will finish after a finite number of pauses, and eventually, all programs will finish execution. If it is a player's turn and all programs have finished execution, that player loses the game, and the other player wins.
Both players play optimally. Who will win?
Input
The first line contains a positive integer $n$, the number of vertices in the graph.
The second line contains $n$ integers $c_1, c_2, \dots, c_n$, representing the color of each vertex. $c_u=0$ means $u$ is a black vertex, and $c_u=1$ means $u$ is a white vertex.
The next $n$ lines describe the edges in the graph. The $i$-th line contains a non-negative integer $m_i$ followed by $m_i$ positive integers $e_{i,1}, e_{i,2}, \dots, e_{i,m_i}$, representing the number of outgoing edges from $i$ and the destination of each edge, respectively. For convenience, it is guaranteed that for all $1 \le i \le n$ and $1 \le j \le m_i$, $e_{i,j} > i$; that is, $1, 2, \dots, n$ is a topological order of the graph.
The next line contains a positive integer $k$, the number of programs.
The last line contains $k$ positive integers $r_1, r_2, \dots, r_k$, representing the input for each program before the game starts.
Output
A single line containing a string representing the winner. If Alice wins, output Alice; if Bob wins, output Bob.
Examples
Input 1
4 1 0 1 0 1 2 2 4 3 1 4 0 1 2
Output 1
Alice
Note 1
The graph has $4$ vertices.
- Vertex $1$: White, one outgoing edge to $2$.
- Vertex $2$: Black, two outgoing edges to $4$ and $3$.
- Vertex $3$: White, one outgoing edge to $4$.
- Vertex $4$: Black, no outgoing edges.
There is only one program, with initial vertex $r=2$. The execution process when both players play optimally is as follows:
- Input initial vertex $r=2$ and pause. The game starts, and it is Alice's turn. Since there is only one program, both players must choose this program. Alice chooses to resume the program.
dfs(2)- Pause. It is Bob's turn. Bob chooses to resume the program.
dfs(4)- Procedure returns.
- Pause. It is Alice's turn. Alice chooses to resume the program.
dfs(3)- Read a boolean value $g$. Alice chooses
false. - Procedure returns.
- Read a boolean value $g$. Alice chooses
- Procedure returns.
- Execution finishes. It is Bob's turn.
When it is Bob's turn, all programs have finished, so Bob loses and Alice wins.
In this example, the existence of vertex $1$ does not affect the game.
Additionally, if Alice chose true in dfs(3), then dfs(3) would call dfs(4), pausing one extra time before the call. This would result in it being Alice's turn when the program finishes, and the winner would be Bob. Since both players play optimally, this does not happen.
Input 2
5 1 1 0 0 1 2 3 5 2 3 5 2 5 4 0 0 2 1 2
Output 2
Bob
Note 2
The two programs have initial vertices $1$ and $2$. Vertices $1$ and $2$ have the same color and outgoing edges, differing only in their labels.
Bob can adopt the following strategy: whenever Alice chooses to execute a program, Bob chooses to execute the other program and provides the same input. It is easy to prove that this is a winning strategy for Bob.
Input 3
10 0 0 0 0 1 1 1 1 0 1 1 2 2 3 4 0 3 5 8 10 1 6 1 7 0 1 9 0 0 1 1
Output 3
Bob
Constraints
For all data:
- $1 \le n \le 2 \times 10^5$
- $c_i \in \{0, 1\}$ (for all $1 \le i \le n$)
- $0 \le m_i \le 4 \times 10^5$ (for all $1 \le i \le n$)
- $\sum_{i=1}^n m_i \le 4 \times 10^5$
- $i < e_{i,j} \le n$ (for all $1 \le i \le n, 1 \le j \le m_i$)
- $1 \le k \le 2 \times 10^5$
- $1 \le r_i \le n$ (for all $1 \le i \le k$)
| Subtask | Score | Special Constraints |
|---|---|---|
| $1$ | $5$ | $c_i=0$ (for all $1 \le i \le n$) |
| $2$ | $15$ | $k=1, r_1=1$ |
| $3$ | $15$ | $n \le 10, \sum_{i=1}^n m_i \le 10, k \le 10$ |
| $4$ | $20$ | $c_i=1$ (for all $1 \le i \le n$); each vertex $u$ has at most one incoming edge; for all $1 \le i \le k$, no edge in the graph ends at $r_i$ |
| $5$ | $20$ | $c_i=1$ (for all $1 \le i \le n$) |
| $6$ | $25$ | No additional constraints |