#C8921. Office Space Optimization

    ID: 52957 Type: Default 1000ms 256MiB

Office Space Optimization

Office Space Optimization

You are given a building with n rooms and k check-in records. Each check-in record contains an employee ID and the room number where the employee checked in. Your task is to determine whether there exist two distinct rooms such that every check-in record occurred in one of these two rooms.

More formally, let the total number of check-in records be \( k \) and let each record be represented as a pair \( (e, r) \), where \( e \) is the employee id and \( r \) is the room number. You need to check if there exist two distinct room numbers \( r_1 \) and \( r_2 \) that cover all the check-in records. That is, every record must satisfy \( r = r_1 \) or \( r = r_2 \).

If the total number of distinct rooms in the records is less than 2, the answer is NO.

The answer should be output as a string: YES if such two rooms exist, and NO otherwise.

inputFormat

The first line of input contains two integers n and k — the total number of rooms and the total number of check-in records.

The following k lines each contain two integers: the employee ID and the room number for a check-in record.

You should read input from stdin.

outputFormat

Output a single line containing YES if there exist two rooms that cover all check-in records; otherwise, output NO.

Your answer should be printed to stdout.

## sample
5 6
1 2
2 3
3 3
4 2
5 2
6 3
YES