#C4970. Seed Planting
Seed Planting
Seed Planting
You are given n seed types and m constraints. There are n fields (numbered from 1 to n), and each seed type must be planted in the same field. Each constraint is given as a pair \( (a,b) \), which indicates that seed type a cannot be planted in field b. Your task is to determine whether there exists at least one field \( f \) (\( 1 \le f \le n \)) such that for every seed type \( i \) \( (1 \le i \le n) \), field \( f \) is not forbidden (i.e. \( f \notin S_i \), where \( S_i \) is the set of fields seed \( i \) cannot be planted in). In other words, check if there exists a field \( f \) such that for all seeds \( i \), there is no constraint \( (i,f) \).
Output YES
if such a field exists, otherwise output NO
.
inputFormat
The input is read from standard input (stdin). The first line contains two integers ( n ) and ( m ) — the number of seed types (and fields) and the number of constraints, respectively. Each of the next ( m ) lines contains two integers ( a ) and ( b ) indicating that seed type ( a ) cannot be planted in field ( b ).
outputFormat
Print a single line to standard output (stdout): YES
if it is possible to plant all seed types in the same field satisfying all constraints, or NO
otherwise.## sample
3 2
1 2
3 1
YES