Under construction

Still being built. Things may change

Matrix Game

Interview

Time limit0.5sMemory limit512 MB

Summary
Given an N by M matrix, it asks who wins a take-away game where a move subtracts 1 to K from the leftmost nonzero entry of some row.
Level

Medium7 of 10

Topics
Game theory, Greedy, Hash map, Matrix
Solved
No attempts yet

Problem

Koosaga and Cubelover are about to play a matrix game. The matrix game is played on an N×M matrix, with the two players taking turns, according to the following rules.

  • Choose a row that contains at least one nonzero number. In that row, choose the leftmost nonzero number. Let the chosen number be K, and decrease it. The number must be decreased by at least 1 and at most K.

The game ends when every number in the matrix becomes 0. The player who decreases a number last wins the game.

Write a program that determines who wins when both players play optimally. Koosaga moves first.

Input

The first line gives N and M. The following N lines give the integers in the matrix. Every number in the input is a natural number less than or equal to 1,000.

Output

If Koosaga wins the game, print "koosaga"; if Cubelover wins, print "cubelover".

Examples5

  1. Example 1

    Input
    2 2
    1 1
    1 1
    
    Expected output
    cubelover
    
  2. Example 2

    Input
    1 3
    2 1 1
    
    Expected output
    koosaga
    
  3. Example 3

    Input
    2 2
    3 2
    3 2
    
    Expected output
    cubelover
    
  4. Example 4

    Input
    3 4
    1 2 3 4
    2 3 4 5
    3 4 5 6
    
    Expected output
    koosaga
    
  5. Example 5

    Input
    4 4
    1 2 1 2
    2 1 2 1
    1 2 1 2
    2 1 2 1
    
    Expected output
    cubelover