Quarry Game
Time limit2sMemory limit512 MB
Each of N piles is a run of M consecutive pile sizes starting at X; a move takes at least one stone from one pile. Decide the winner under optimal play.
- Level
Hard9 of 10
- Topics
- Game theory, Math, Combinatorics, Number theory
- Solved
- No attempts yet
Problem
Koosaga and Cubelover own quarries. Today they want to play a game with the quarries.
Each quarry holds some dump trucks. The number of dump trucks parked in the -th quarry is . Each dump truck carries stones: the first truck carries stones, the second carries stones, the third carries stones, ..., and the -th truck carries stones.
The two players take turns, and Koosaga moves first. On your turn you must choose one dump truck and remove stones from it. The number of stones removed must be at least 1. The player who cannot remove any more stones loses.
Write a program that determines who wins when both players play optimally.
Input
The first line gives the number of quarries (). The next lines give the quarry information. Each quarry is described by two integers ().
Output
Print "koosaga" if Koosaga wins, and "cubelover" if Cubelover wins.