CF103B.Cthulhu

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...

Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super weapon. Due to high seismic activity and poor weather conditions the satellites haven't yet been able to make clear shots of the monster. The analysis of the first shot resulted in an undirected graph with nn vertices and mm edges. Now the world's best minds are about to determine whether this graph can be regarded as Cthulhu or not.

To add simplicity, let's suppose that Cthulhu looks from the space like some spherical body with tentacles attached to it. Formally, we shall regard as Cthulhu such an undirected graph that can be represented as a set of three or more rooted trees, whose roots are connected by a simple cycle.

It is guaranteed that the graph contains no multiple edges and self-loops.

输入格式

The first line contains two integers — the number of vertices nn and the number of edges mm of the graph (1n1001 \le n \le 100, 0mn(n1)20 \le m \le \frac{n(n-1)}{2}).

Each of the following mm lines contains a pair of integers xx and yy, that show that an edge exists between vertices xx and yy (1x,yn,xy1 \le x, y \le n, x \ne y). For each pair of vertices there will be at most one edge between them, no edge connects a vertex to itself.

输出格式

Print "NO", if the graph is not Cthulhu and "FHTAGN!" if it is.

输入输出样例

  • 输入#1

    6 6
    6 3
    6 4
    5 1
    2 5
    1 4
    5 4
    

    输出#1

    FHTAGN!
  • 输入#2

    6 5
    5 6
    4 6
    3 1
    5 1
    1 2
    

    输出#2

    NO

说明/提示

Let us denote as a simple cycle a set of vv vertices that can be numbered so that the edges will only exist between vertices number 11 and 22 , 22 and 33 , ..., v1v-1 and vv , vv and 11 .

A tree is a connected undirected graph consisting of nn vertices and n1n-1 edges ( n>0 ).

A rooted tree is a tree where one vertex is selected to be the root.

首页