Alice and Bob are bored from playing Nim, so they modified that game — ArbiNim has been created just now. Rules of game is very simple:
There are k piles of stones such that there are ai stones in i'th pile.
Alice and Bob are making moves alternatively, as Bob is gentlemen Alice starts first.
In each move, player selects one of non-empty piles and takes some of stones from that pile and throws away. From remaining stones (if there are) in selected pile, player takes any number of stones again and distributes them arbitrarily to non-empty piles.
The player who takes last stone wins.
Bob can be gentlemen and give some opportunities to his opponent Alice the optimal mover, but as we know, he is merciless in games, he will play optimal also!
Your task is determining winner of game, GAME ON!
P.S. If you know source of problem or some judge to submit, please mention it.