Under construction

Still being built. Things may change

What Happens When All the Branches Fall From a Tree?

Time limit1sMemory limit1024 MB

Summary
Two players take turns removing a root-to-vertex path from a tree, and a Nim game on the removed stones decides each turn. The task is to find the winner.
Level

Hard8 of 10

Topics
Tree, Game theory, Dynamic programming, Bit manipulation
Solved
No attempts yet

문제

가지런하다 (even and tidy)

Dongwoo and Jaewoo play a game on a tree TT with NN vertices, numbered 11 to NN. The root of the tree is vertex 11, and vertex ii has CiC_i stones. The game starts with Dongwoo, and the two players take turns. A turn is defined as follows.

Let A be the player whose turn it is, and B the other player. Let FF be the current forest. At the start, F={T}F=\{T\}.

  1. A picks one tree in FF. If no tree remains, A loses.
  2. Let T0T_0 be the chosen tree, and let rr be its root.
  3. A picks a vertex vv in T0T_0 and takes every vertex on the path from rr to vv, including both endpoints. If r=vr=v, A takes only rr.
  4. Using the taken vertices, B and A play a Nim game, starting with B. Players alternate. On each move, a player picks a vertex with at least one stone and takes any positive number of stones from it. The player who cannot move loses.
  5. If B wins this Nim game, B immediately wins the original game.
  6. If A wins the Nim game, A rearranges T0T_0 as follows. For each vertex directly connected to rr in T0T_0, add the subtree rooted at that vertex to FF, except the subtree that contains vv. Then remove T0T_0 from FF.

The forest starts with one tree, but as the game goes on, it can become a collection of several trees that are not connected to each other.

A player who cannot act on their turn loses. Assuming both players play optimally, determine who wins.

Input

The first line contains the number of vertices NN (1≤N≤200 0001 \le N \le 200\,000).

The second line contains the stone counts C1,C2,⋯ ,CNC_1, C_2, \cdots, C_N (0≤Ci≤1090 \le C_i \le 10^9), separated by spaces. Vertex ii has CiC_i stones.

Each of the next N−1N-1 lines contains two vertex numbers Pi,QiP_i, Q_i (1≤Pi,Qi≤N1 \le P_i, Q_i \le N, Pi≠QiP_i \ne Q_i), separated by a space, that are directly connected in the tree.

The input is guaranteed to be a tree.

Output

If Dongwoo wins, print kidw0124 on the first line. If Jaewoo wins, print eoaud0108.

Hint

The title of this problem and the answer to it are the idea of kidw0124.

Examples5

  1. Example 1

    Input
    1
    0
    
    Expected output
    kidw0124
    
  2. Example 2

    Input
    1
    1
    
    Expected output
    eoaud0108
    
  3. Example 3

    Input
    2
    124 124
    1 2
    
    Expected output
    kidw0124
    
  4. Example 4

    Input
    2
    124 108
    1 2
    
    Expected output
    eoaud0108
    
  5. Example 5

    Input
    4
    1 1 2 2
    1 2
    1 3
    3 4
    
    Expected output
    eoaud0108