#P2284. [HNOI2003] 密室之门
[HNOI2003] 密室之门
Description
Recently, archaeologists in China discovered several secret chambers in a new pit of the Terracotta Army, each accessible through a peculiar door. How can a chamber be entered?
On the door to the -th chamber, there are dials. The -th dial of this chamber is evenly divided into cells, numbered in clockwise order as . Each dial has a hand (similar to a clock). Approximately every 1.53 seconds, a hand that was pointing at the cell numbered advances to point at the cell numbered . When, for a door, the hands on all its dials simultaneously point to the cell numbered , the door opens.
However, when the chambers were discovered, the hands on the dials pointed to various indices. Based on the opening rule, it was determined that some chambers can never be opened. Your task is to determine which doors can possibly be opened.
Input Format
The first line contains , the number of chambers. The data that follows is divided into groups, each describing one door. In group , the first line contains , the number of dials on that door. Each of the next lines contains two integers: the first is , and the second is the index of the cell the hand was pointing to when the chamber was discovered.
Output Format
Output lines. For the -th chamber, print possible if its door can be opened; otherwise, print impossible. Note: use lowercase.
2
2
5 3
4 2
2
4 3
6 2
possible
impossible
Hint
Constraints: For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号