QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#17892. Lawyers

الإحصائيات

$N$ lawyers have been indicted for fraud. The $N$ lawyers intend to defend each other to ensure everyone is acquitted.

Lawyer $A$ can defend lawyer $B$ if and only if lawyer $B$ trusts lawyer $A$. There are $M$ such pairs $(A, B)$ where this is possible.

Since each lawyer is highly skilled, anyone who receives at least one defense is guaranteed to be acquitted.

However, if two lawyers $A$ and $B$ defend each other (i.e., $A$ defends $B$ and $B$ defends $A$), it is considered highly suspicious, and both will be found guilty.

For each pair $(A, B)$, you must decide whether lawyer $A$ will defend lawyer $B$ such that every lawyer is acquitted. Determine if this is possible.

Input

The first line contains $N$ and $M$ ($1 \le N, M \le 200000$). The following $M$ lines each contain $A_i$ and $B_i$ ($1 \le A_i, B_i \le N$, $A_i \neq B_i$).

This means lawyer $A_i$ can defend lawyer $B_i$. No pair $(A, B)$ appears more than once.

Output

If it is possible for every lawyer to receive at least one defense while ensuring no two lawyers defend each other, output YES on the first line. Otherwise, output NO.

Examples

Input 1

3 3
1 2
2 3
3 1

Output 1

YES

Input 2

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

Output 2

NO

Input 3

4 4
1 2
2 1
3 4
4 3

Output 3

NO

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.