#P2691. 逃离
逃离
Description
Translated from CLRS Problem 26-1: Escape problem.
In an grid, there are starting points , , , . Determine whether it is possible to find a path for each starting point to the boundary such that these paths are pairwise disjoint (that is, no two paths share any point).

Black dots indicate starting points, and other points are white. The found paths are shown with bold lines. In figure (a), there exist valid paths; in figure (b), there do not.
Input Format
The first line contains an integer ().
The second line contains an integer ().
Each of the following lines, the -th line, contains two integers and , meaning that the point at row , column is a starting point. The starting points are guaranteed to be distinct.
Output Format
Output a single line. If an escape exists, output YES; otherwise, output NO.
6
10
2 2
2 4
2 6
3 1
3 2
3 4
3 6
4 2
4 4
4 6
YES
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号