#P7216. [JOISC 2020] 美味しい美味しいハンバーグ
[JOISC 2020] 美味しい美味しいハンバーグ
Description
There is a metal grid, where denotes the cell in the -th column from left to right and the -th row from top to bottom (). On this grid, there are hamburger patties, numbered . The -th patty is placed inside the rectangular region with bottom-left corner and top-right corner . Patties may overlap.
You need to check whether all patties are cooked. You may choose cells on the metal grid and insert a bamboo skewer vertically through the center of each chosen cell. For each patty, you can confirm whether it is cooked by inserting a skewer into a cell that the patty occupies. Of course, you may insert multiple skewers into the same cell, or insert skewers into cells with no patty, although that is unnecessary.
Formally, you need to find points that satisfy the following conditions:
-
For every , there exists a such that and .
-
For every , .
You need to write a program to output these points . The testdata guarantees that a solution exists.
Input Format
The first line contains two integers , as described above.
The next lines each contain four integers , describing one hamburger patty.
Output Format
Output lines, each containing two integers and .
If there are multiple solutions, you may output any one.
4 2
2 1 3 3
1 2 4 3
6 1 7 4
5 3 7 5
2 2
7 4
3 3
1 1 1 1
1 2 1 2
1 3 1 3
1 1
1 2
1 3
Hint
Explanation of Sample 1
Inserting a bamboo skewer at can confirm whether the first two patties are cooked, and inserting a bamboo skewer at can confirm whether the last two patties are cooked.
Another feasible solution is to insert bamboo skewers at and .
Subtasks
| Subtask ID | Special Property | Score |
|---|---|---|
For of the testdata, , , , and . The testdata guarantees that a solution exists.
Translated by ChatGPT 5
京公网安备 11011102002149号