Barbarian tribes P59892


Statement
 

pdf   zip

In a lost land two primitive tribes coexist: Gareds and Kekas. Every summer solstice they meet and compete to decide which tribe will be the favorite of the gods for the rest of the year, following an old ritual:

First, a local guru chooses three numbers at random: nn, mm and kk. Afterwards, nn Gared maids (in the positions 1,,n1, \dots, n) and mm Keka maids (in the positions n+1,,n+mn+1, \dots, n+m) are placed in a circle looking inwards. Then the guru begins to count 1,,k1, \dots, k starting at the first Gared maid. When the kk-th maid is reached, she is immediately sacrificed to the gods. The guru then counts again 1,,k1, \dots, k starting at the maid following the one just sacrificed. Again, the kk-th maid reached this way is sacrificed. After every two sacrifices, the second sacrificed maid is replaced by a new maid. In order to decide the tribe of the new maid, the guru looks at the heads of the two maids just killed (nothing else remains of them). If both heads are of the same tribe, the guru calls a Gared maid. If the heads are from different tribes, the guru calls a Keka maid. The process then begins again (counting and sacrificing twice and replacing once) starting to count at the maid following the new maid just added to the circle. Since the number of maids is reduced by one after every step (of two sacrifices and one replacement), after n+m1n+m-1 steps only one maid remains.

According to the tradition, the tribe of the last maid will be the favorite of the gods. (What the guru does to the last maid is something you don’t want to know.) Anyway, write a program such that, given nn, mm and kk, writes the name of the fortunate tribe.

For example, this is what happens for n=m=3n = m = 3 and k=2k = 2 (a “G” denotes a Gared maid and a “K” denotes a Keka maid; the subindexes mark the order the maids enter the circle):

  1. Initial content of the circle: G1_1 G2_2 G3_3 K4_4 K5_5 K6_6
    Starting to count at G1_1. First sacrifice: G2_2. Second sacrifice: K4_4 (replaced by K7_7).

  2. Content of the circle: G1_1 G3_3 K7_7 K5_5 K6_6
    Starting to count at K5_5. First sacrifice: K6_6. Second sacrifice: G3_3 (replaced by K8_8).

  3. Content of the circle: G1_1 K8_8 K7_7 K5_5
    Starting to count at K7_7. First sacrifice: K5_5. Second sacrifice: K8_8 (replaced by G9_9).

  4. Content of the circle: G1_1 G9_9 K7_7
    Starting to count at K7_7. First sacrifice: G1_1. Second sacrifice: K7_7 (replaced by K10_{10}).

  5. Content of the circle: G9_9 K10_{10}
    Starting to count at G9_9. First sacrifice: K10_{10}. Second sacrifice: G9_9 (replaced by K11_{11}).

  6. Final content of the circle: K11_{11}

Input

Input consists of several cases, each with three natural numbers nn, mm and kk. You can assume 1n+m20001 \le n + m \le 2000 and 1k10001 \le k \le 1000. A special case with n=m=k=0n = m = k = 0 ends the input.

Output

For every case, print either "Gared" or "Keka" as convenient.

Public test cases
  • Input

    3 3 2
    4 2 2
    0 1 7
    0 0 0
    

    Output

    Keka
    Gared
    Keka
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++