QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100

#6666. Graph

统计

For a non-negative integer $k$, we define the concept of a $k$-triple graph recursively as follows.

A graph is said to be 0-triple if it consists of exactly one vertex.

For $k \ge 1$, a graph is said to be $k$-triple if it is formed by taking three $(k-1)$-triple graphs $G$, $H$, and $I$, choosing one vertex from each of those three graphs, and adding three new edges connecting the chosen vertices.

The image below shows a 3-triple graph.

Your task is to determine, for a given input graph, whether it is $k$-triple for some $k$.

Input

The first line contains two natural numbers $N$ and $M$, representing the number of vertices and the number of edges in the graph, respectively.

Each of the following $M$ lines contains two natural numbers $a$ and $b$ ($1 \le a, b \le N$), which represent an edge between vertices $a$ and $b$. No edge connects a vertex to itself, and no edge will be listed twice.

Output

In a single line, print da if the given graph is $k$-triple for some $k$, and ne otherwise.

Subtasks

In all subtasks, $1 \le N \le 200\,000$ and $1 \le M \le 300\,000$.

Subtask Points Constraints
1 15 $N \le 10, M \le 20$
2 20 $N \le 1000, M \le 2000$
3 15 If the graph is $k$-triple, it is guaranteed that it was formed such that in each step, exactly three vertices were chosen, each of which was chosen in the previous step in the corresponding graph of lower triple-degree. (The "middle" vertex is always chosen.)
4 50 No additional constraints.

Examples

Input 1

3 3
1 2
2 3
3 1

Output 1

da

Input 2

9 12
1 2
2 3
3 1
3 4
4 5
3 5
5 6
6 7
7 5
7 8
9 8
7 9

Output 2

ne

Input 3

9 12
1 2
2 3
3 1
4 5
5 6
6 4
7 8
8 9
9 7
1 7
7 4
4 1

Output 3

da

Note

Explanation of the third example: This refers to "one third" of the graph from the image above, i.e., a 2-triple graph.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.