Under construction

Still being built. Things may change

Everything Is New

Time limit1sMemory limit1024 MB

Summary
Given a shuffled Ukdimensional sliding puzzle on an a x b x c x d x e x f grid, decide whether the pieces can be returned to the solved order.
Level

Hard8 of 10

Topics
Math, Graph, Implementation
Solved
No attempts yet

Problem

Uk-jae says every math problem is 2ez. Ask him about an unsolved problem such as the Riemann hypothesis, and he will still answer '2ez'. When someone asks for the actual solution, he dodges by saying it is too easy to be worth answering. The trick is obvious, since it clearly shows he does not know the solution, but he cannot prove that, so it works as his usual irritating bait.

Uk-jae has one weakness: problems with a false premise. If he answers '2ez' to one of those, a bored person like Jeultalleuler will reply with something like 'That's wrong, how did you prove it lol' and mock him.

Jeultalleuler targeted Uk-jae by making a 'Ukdimensional sliding puzzle' and sending it to him by hand. This puzzle extends the familiar two-dimensional sliding puzzle to six dimensions. Specifically, a Ukdimensional sliding puzzle of size a×b×c×d×e×fa \times b \times c \times d \times e \times f has N=abcdefN = abcdef cells in six dimensions. Each cell is located by six coordinates (i,j,k,l,m,n)(i, j, k, l, m, n) with 1≤i≤a1 \leq i \leq a, 1≤j≤b1 \leq j \leq b, 1≤k≤c1 \leq k \leq c, 1≤l≤d1 \leq l \leq d, 1≤m≤e1 \leq m \leq e, and 1≤n≤f1 \leq n \leq f. In other words, every coordinate is a positive integer no greater than its maximum. In the initial state, every cell except the empty cell (a,b,c,d,e,f)(a, b, c, d, e, f) holds one piece.

In this puzzle, you can move a piece next to the empty cell into the empty cell. Let the empty cell be p0=(i0,j0,k0,l0,m0,n0)p_0 = (i_0, j_0, k_0, l_0, m_0, n_0). A piece at p1=(i1,j1,k1,l1,m1,n1)p_1 = (i_1, j_1, k_1, l_1, m_1, n_1) can move to p0p_0 if exactly one coordinate of p1p_1 differs from the matching coordinate of p0p_0 by 1, and all other coordinates are equal. Equivalently, exactly one of ∣i0−i1∣,∣j0−j1∣,⋯|i_0 - i_1|, |j_0 - j_1|, \cdots is 1 and the rest are 0. The piece moves from p1p_1 to p0p_0, so the new empty cell is at p1p_1. Given a shuffled state, the goal is to restore the pieces to their initial order.

Uk-jae does not plan to solve the puzzle. He will just call it 2ez. But this puzzle may be impossible to return to the initial state. Jeultalleuler will call Uk-jae and ask him to say '2ez' if the puzzle can be solved, and 'eokkkkkk' if it cannot. Help Uk-jae pick the right answer so he can stir up trouble without getting mocked.

Input

The first line contains the sizes a,b,c,d,e,fa, b, c, d, e, f in that order.

The second line contains N=abcdefN = abcdef numbers that give the piece in each cell. Each number is between 00 and N−1N-1, inclusive, and all numbers are distinct. 00 denotes the empty cell, and each number from 11 upward denotes a piece. The pieces are given in lexicographic order of their coordinates. That is, the coordinates are listed as

(1,1,1,1,1,1),(1,1,1,1,1,2),⋯ ,(1,1,1,1,1,f),(1,1,1,1,2,1),(1,1,1,1,2,2),⋯ ,(1,1,1,1,2,f),⋯⋯(1,1,1,1,e,1),(1,1,1,1,e,2),⋯ ,(1,1,1,1,e,f),(1,1,1,2,1,1),(1,1,1,2,1,2),⋯ ,(1,1,1,2,1,f),⋯⋯⋮(a,b,c,d,e,1),(a,b,c,d,e,2),⋯ ,(a,b,c,d,e,f)\begin{aligned} (1, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, 2), \cdots, (1, 1, 1, 1, 1, f), \\\\ (1, 1, 1, 1, 2, 1), (1, 1, 1, 1, 2, 2), \cdots, (1, 1, 1, 1, 2, f), \\\\ \cdots \cdots \\\\ (1, 1, 1, 1, e, 1), (1, 1, 1, 1, e, 2), \cdots, (1, 1, 1, 1, e, f), \\\\ (1, 1, 1, 2, 1, 1), (1, 1, 1, 2, 1, 2), \cdots, (1, 1, 1, 2, 1, f), \\\\ \cdots \cdots \\\\ \vdots \\\\ (a, b, c, d, e, 1), (a, b, c, d, e, 2), \cdots, (a, b, c, d, e, f) \end{aligned}

The solved state is written as 1,2,⋯ ,N−1,01, 2, \cdots, N-1, 0 in this notation.

Output

Print '2ez' if the puzzle can be solved, and 'eokkkkkk' otherwise (without the quotes).

Constraints

  • a,b,c,d,e,f≥1a, b, c, d, e, f \geq 1
  • N=abcdef≤106N = abcdef \leq 10^6
  • At least one of a,b,c,d,e,fa, b, c, d, e, f is 2 or greater.

Examples2

  1. Example 1

    Input
    1 1 1 1 4 4
    1 2 3 4 5 6 7 8 9 10 11 12 13 15 14 0
    
    Expected output
    eokkkkkk
    
  2. Example 2

    Input
    1 1 1 2 2 2
    2 6 3 4 1 0 5 7
    
    Expected output
    2ez