Decide the winner of a turn-based card game where each move trims one of many piles by up to K cards plus the value shown on the new top card.
Medium7Game theoryDynamic programmingNo attempts yetTime limit1sMemory limit256 MBAlice and Bob invented a game at the beach this summer. All they need is a deck of numbered cards. They lay every card face up in P piles and pick a number K. Then they take turns like this.
A player who has no cards left to remove loses, and so does a player who has to remove more cards than the pile holds.

The figure shows a position with two piles and K=1. The first pile holds one card showing 1, and the second pile holds three cards showing 1, 2 and 1 from the bottom to the top. The player to move has three options.
Bob is very good at this game and wins whenever he has the chance. This time Alice moves first. Decide whether Alice can win.
The first line contains two space separated integers P and K, the number of piles and the largest number of cards a player may remove at the start of a turn.
Each of the next P lines describes one pile. The line starts with an integer N, the number of cards in that pile, followed by N space separated integers giving the cards from the bottom to the top.
Print Alice can win. if Alice wins, and Bob will win. otherwise, on a single line.