시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 3 3 3 100.000%

문제

I have drawn n dots on a plane and m straight segments connecting these dots. No segment goes through dots other than its endpoints, and no two segments intersect in any point other than their common endpoint. Also, if you start in one dot and move only by segments, you can go to any other dot. All n dots are in distinct positions.

Yes, that’s a planar embedding of some connected graph with n vertices and m edges. Your task is to check if each face of this graph, including the outer face, is a triangle. Face is a triangle if and only if it is bounded by exactly 3 edges. If face is on both sides of some edge, this edge is counted twice.

Strive for excellence! Allow yourself nothing less than the best possible complexity for your algorithm.

입력

The first line contains two integers n and m (3 ≤ n ≤ 105, n − 1 ≤ m ≤ 3 · 105) — the number of dots and the number of segments, respectively.

The next n lines contain coordinates of dots. All the coordinates are not greater than 109 by absolute value. All n dots are in distinct positions.

Each of the next m lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the ids of dots connected by a segment. It is guaranteed that there are no two segments connecting the same pair of dots.

It is guaranteed that the input describes a valid planar embedding of a connected graph with all edges drawn as straight segments.

출력

If each face of the given graph, including its outer face, is a triangle, print “YES”, otherwise print “NO”.

예제 입력 1

3 3
0 0
1 0
0 1
1 2
2 3
3 1

예제 출력 1

YES

예제 입력 2

4 4
0 0
3 0
0 3
1 1
1 2
2 3
3 1
1 4

예제 출력 2

NO

예제 입력 3

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

예제 출력 3

YES

예제 입력 4

4 5
0 0
2 0
1 1
0 2
1 2
1 3
1 4
2 3
3 4

예제 출력 4

NO

예제 입력 5

4 3
0 0
0 1
1 1
1 2
1 2
2 3
3 4

예제 출력 5

NO