Under construction

Still being built. Things may change

DAGame

Time limit1sMemory limit1024 MB

Summary
Two players take turns moving tokens along DAG edges, and same-colored token pairs move together once they meet. Output the winner under optimal play.
Level

Hard8 of 10

Topics
Game theory, Dynamic programming, Graph, Topological sort
Solved
No attempts yet

Problem

Woo-young and Hyeon-cheol bet on a set of Yeongcheol Burger Don Mari meals. Hyeon-cheol made the following game.

A DAG (directed graph without cycles) has NN nodes and MM edges. KK pieces each sit on one of the nodes. There is no limit on how many pieces can sit on a node. Each piece has a color, written as an integer from 11 to NN. At most two pieces have any given color. Young and Cheol take turns, starting with Young. On a turn, a player picks one piece and moves it along an outgoing edge of its node to the next node. If two pieces of the same color sit on the same node, they stack and move together from then on. Pieces of different colors never affect each other. Pieces may already be stacked before the game starts. A player who cannot make a move on their turn loses. Given the initial graph and pieces, output who wins if both players play optimally.

Input

The first line contains the number of nodes NN (2≤N≤5002 \le N \le 500) and the number of edges MM (1≤M≤100 0001 \le M \le 100\,000).

Each of the next MM lines contains two distinct integers pp and qq (1≤p,q≤N1 \le p, q \le N), meaning there is an edge from node pp to node qq. The same edge may appear more than once.

The next line contains the number of pieces KK. (1≤K≤2⋅N1 \le K \le 2 \cdot N)

Each of the next KK lines contains two integers viv_i and cic_i (1≤i≤K1 \le i \le K), meaning piece ii has color cic_i and sits on node viv_i. (1≤vi,ci≤N1 \le v_i, c_i \le N)

The given graph is guaranteed to be a DAG.

Output

If Young wins, print Young. If Cheol wins, print Cheol.

Examples3

  1. Example 1

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

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

    Input
    12 12
    1 2
    2 3
    3 4
    1 5
    5 4
    6 5
    7 8
    8 9
    9 10
    7 11
    11 10
    12 11
    4
    1 1
    6 1
    7 2
    12 2
    
    Expected output
    Cheol