G - Yet Another Game of Stones
Alice and Bob are playing yet another game of stones. The rules of this game are as follow:
- The game starts with n piles of stones indexed from 1 to n. The i-th pile contains ai stones and a special constraint indicated as bi.
- The players make their moves alternatively. The allowable moves for the two players are different.
- An allowable move of Bob is considered as removal of some positive number of stones from a pile.
- An allowable move of Alice is also considered as removal of some positive number of stones from a pile, but is limited by the constraint bi of that pile.
- If bi = 0, there are no constraints.
- If bi = 1, Alice can only remove some odd number of stones from th