Andy and Andrew are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they always find the best strategy, and that's why they feel bored again and again. They just invented a new game, as they usually did.
At the beginning of the game, they write down one string $S=s_1s_2s_3 \ldots s_k$, and then they take turns(Andy first) to either:
1. Erase the leftmost character from $S$, that is, $S=s_2s_3s_4 \ldots s_k$.
2. Erase the rightmost character from $S$, that is, $S=s_1s_2s_3 \ldots s_{k-1}$.
Whenever $S$ is empty or $S \in A$ ($A$ is a given list of strings), the player which plays next loses the game.
For example, let $S=dzxx$ and $A=\{z,dz\}$. If Andy erases 'x' then Andrew can erase another 'x', because $S=dz$ and $dz$ is in $A$, Andy, the next player, loses. Otherwise, Andy erases 'd', and then Andrew can erase 'z' result in a losing position for Andy.
You are given a string $T=t_1t_2t_3\ldots t_n$ and a list of string $A=\{a_1,a_2,\ldots,a_m\}$. Your task is to find who is the winner if $S$ is some substring of $T$. Andy and Andrew play so many times so you need to answer multiple queries.