luogu#P4885. 灭顶之灾
灭顶之灾
Background
Please read the initials of the pinyin of the problem name together.
Problem Description
Scarlet has a mysterious table. Now Scarlet fills numbers into the table. She will start from some cell in the first row, and then, in the order of left to right, top to bottom, she fills positive integers starting from , until she fills the last row completely.
To let you determine this table, Scarlet will tell you groups of consecutive numbers in the same row. After that, Scarlet will ask you queries. You need to answer, for each queried number, which row and which column it is filled in.
Input Format
The first line contains positive integers .
The next lines each contain two positive integers , meaning that the integers from to are in the same row of the table and are consecutive.
The next lines each contain one positive integer , representing the number in each query.
Output Format
If no table satisfying the constraints exists, output one line Impossible!.
Otherwise, if the table satisfying the constraints is not unique, output one line Uncertain!.
Otherwise, output the xor sum of all row and column results (including the earlier 0 0 cases), in order to reduce the output file size so that Scarlet can easily upload the testdata to the server.
3 4 2 2
8 9
2 4
9
3
7
Hint
Table:
0001
2345
6789
is in row , column .
is in row , column .
( means the xor operation).
Constraints
For of the data, .
For of the data, .
For of the data, , , and .
Translated by ChatGPT 5