Under construction

Still being built. Things may change

Moorbles

Time limit2sMemory limit1024 MB

Summary
Given N marbles and M turns with K possible bets per turn, find the lexicographically smallest Even/Odd guess sequence that keeps Elsie from losing, or print -1.
Level

Hard8 of 10

Topics
Dynamic programming, Game theory, Greedy
Solved
No attempts yet

Problem

Bessie and Elsie are playing a game of Moorbles. The game works as follows: Bessie and Elsie each start out with some amount of marbles. Bessie holds out AA of her marbles in her hoof and Elsie guesses if AA is Even or Odd. If Elsie is correct, she wins the AA marbles from Bessie. If she guesses incorrectly, she loses AA of her marbles to Bessie. If Elsie has less than AA marbles, she loses all her marbles. A player loses when they lose all of their marbles.

After some amount of turns in the game, Elsie has NN (1≤N≤109)(1 \leq N \leq 10^9) marbles. She thinks it is hard to win, but she is playing to not lose. After being around Bessie enough, Elsie has a good read on Bessie's habits. She recognizes that on turn ii, there are only KK (1≤K≤4)(1 \leq K \leq 4) different amounts of marbles that Bessie may put out. There are only MM (1≤M≤3⋅105)(1 \leq M \leq 3 \cdot 10^5) turns before Bessie gets bored and stops playing. Can you identify a lexicographically minimum turn sequence such that Elsie will not lose, regardless of how Bessie plays?

Input

The first line contains a single integer TT (1≤T≤101 \leq T \leq 10), the number of test cases. Each test case is described as follows.

The first line contains three integers NN, MM, and KK, the number of marbles Elsie has, the number of turns, and the number of potential moves Bessie can make, respectively.

Then MM lines follow. Line ii contains KK distinct space separated integers ai,1ai,2…ai,Ka_{i,1} a_{i,2} \ldots a_{i,K} (1≤ai,j≤1031 \leq a_{i,j} \leq 10^3), the possible amounts of marbles that Bessie might play on turn ii.

It is guaranteed that the sum of MM over all test cases is at most 3⋅1053 \cdot 10^5.

Output

For each test case, output the lexicographically minimum move sequence for Elsie to guarantee not losing, or −1-1 if she will lose. The move sequence is a single line with MM space-separated tokens, each equal to either "Even" or "Odd". Note that "Even" is lexicographically smaller than "Odd".

Examples2

  1. Example 1

    Input
    2
    10 3 2
    2 5
    1 3
    1 3
    10 3 3
    2 7 5
    8 3 4
    2 5 6
    
    Expected output
    Even Even Odd
    -1
    
  2. Example 2

    Input
    1
    20 8 2
    3 5
    3 5
    3 5
    3 5
    3 5
    3 5
    3 5
    3 5
    
    Expected output
    Even Even Even Odd Even Odd Even Odd