The game of NimForK is played as follows. There are k players sitting in a circle numbered 1 through k in clockwise order. Starting with player 1, the players take turns making moves in clockwise order. In the center of the circle, there is a pile that initially contains n stones.
When a player takes a turn, he must remove some number of stones from the pile. The number of stones he is allowed to take is dependent on the size of the pile. You are given a String moves, where the i-th element (1-indexed) is a space separated list of the number of stones that can be removed when the pile contains i stones. For example, if there are currently 3 stones in the pile, and moves is "1 3", then the player can remove either 1 stone or 3 stones from the pile. The player who takes the last stone wins.
Each player uses the following strategy to determine how many stones he will remove during his turn:
- If there is a move that ensures he will win regardless of how the other players move for the rest of the game, he will make that move. If there are several such moves, he will randomly choose one of them with equal probability. In other words, pretend that the other players are not following the strategy described here, and that it's possible for them to make any valid moves during their turns. If there is a move that will guarantee him to win in that scenario, he will make that move.
- If there is no such move, then assuming that the other players are following this same strategy, he will make a move that gives him a non-zero chance of winning. If there are several such moves, he will randomly choose one of them with equal probability.
- If neither of the above moves are possible, he will randomly choose any valid move with equal probability.
If there are no valid moves possible during a player's turn, but there are still stones left in the pile, the game ends and nobody wins.
Return a int containing all the players who have a non-zero chance of winning the game. The int must be sorted in ascending order.