After her previous artwork was met with critical acclaim, Bessie was offered a job designing painting sets. She designs these paintings by choosing
Still being an avant-garde artist, Bessie decides that the painting should resemble a Holstein cow. More specifically, each region formed by the rectangles is colored either black or white, no two adjacent regions have the same color, and the region outside of all the rectangles is colored white.
After choosing the rectangles, Bessie would like you to output one of two things based on a parameter
Subtasks # | Score | Constraints |
---|---|---|
1 | 9 | |
2 | 14 | No two rectangle boundaries intersect |
3 | 14 | The boundaries of all rectangles are connected |
4 | 14 | The boundaries of all rectangles are connected |
5 | 24 | |
6 | 25 |
The first line contains
The next
It is guaranteed that all the
A single integer if
Sample Input 1 | Sample Output 1 |
2 1
|
4
|
There are two white regions and two black regions, for a total of four regions. The boundaries of all rectangles are connected, so this input would satisfy the conditions of subtask 3.
Sample Input 2 | Sample Output 2 |
5 2
|
4
|
The boundary of the rectangle in the upper-right is not connected to the rest of the boundaries, so this input would not satisfy the conditions of subtask 4.
Subtask | Score |
---|---|
1 | 9 |
2 | 14 |
3 | 14 |
4 | 14 |
5 | 24 |
6 | 25 |
7 | 0 |