Under construction

Still being built. Things may change

Composite Functions for the Chairman

Interview

Time limit1sMemory limit1024 MB

Summary
Given an integer quadratic f and a linear g, count the x-values where f(g(x)) equals g(f(x)) and report the matching phrase.
Level

Medium4 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

The chairman has a difficult personality. When he is pleased, he says "Nice" or "Go ahead". When he is not pleased, he says "Remember my character". If someone crosses his line, he rebukes them mercilessly with "Head on".

His request is to build a composite function from two polynomials f(x)f(x) and g(x)g(x).

Let p(x)=f(g(x))p(x) = f(g(x)) and q(x)=g(f(x))q(x) = g(f(x)). The highest degree of f(x)f(x) is at most 2, and the highest degree of g(x)g(x) is at most 1. The chairman reacts to the number of points where y=p(x)y=p(x) and y=q(x)y=q(x) meet. If there are infinitely many points, he says "Nice". If there are two, he says "Go ahead". If there is one, he says "Remember my character". If there are none, he says "Head on".

The number of meeting points can be found by counting the points where p(x)−q(x)=0p(x)-q(x)=0 meets the x-axis.

Input

The first line contains the coefficient of the x2x^2 term, the coefficient of the xx term, and the constant term of f(x)f(x), separated by spaces, in that order. The second line contains the coefficient of the xx term and the constant term of g(x)g(x), separated by spaces, in that order.

All coefficients and constant terms are integers from -20 to 20.

Output

Print one of "Nice", "Go ahead", "Remember my character", or "Head on", depending on the number of points where the two functions meet.

Examples4

  1. Example 1

    Input
    2 4 0
    2 0
    
    Expected output
    Remember my character
    
  2. Example 2

    Input
    0 2 4
    2 4
    
    Expected output
    Nice
    
  3. Example 3

    Input
    1 1 1
    5 0
    
    Expected output
    Go ahead
    
  4. Example 4

    Input
    1 3 2
    0 4
    
    Expected output
    Head on