#Lutece2686. F_know's Binary Matrix
F_know's Binary Matrix
Migrated from Lutece 2686 F_know's Binary Matrix
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
F_know invites you to play an interesting game on a binary matrix with rows and columns, consisting of either or . Initially, the number of is .
Now he gives you an integer and you can do the following operation on the matrix any number (possibly zero) of times you want.
- Choose a contiguous submatrix of size or .
- Flip every number in the submatrix. That is, if it is , change it to , and vice versa.
Your goal is to make all numbers in the matrix become . Determine whether you can do it or not.
Input
The first line contains two integers and (), denoting the initial number of and the size of the submatrix.
For the next lines, each line contains two integers and (), denoting that a number locates at -th row and -th column. It's guaranteed that all the positions in the input are distinct.
Output
If you can make all numbers become , output . Otherwise, output .
Samples
4 2
1 1
1 3
1 4
2 2
YES
4 3
2 2
1 3
3 3
3 1
NO
Note
In the first example, you can make it by the following steps.
In the second example, it's impossible to achieve the goal.
Resources
电子科技大学第十二届 ACM 趣味程序设计竞赛