Problem I
Terminal Tools
Wanting to be more like Tore the Terminal Terminator you want to create the most magnificant command line tool ever. The greatest command line interface (CLI) must clearly be the one with the most options available. An option is simply a feature that can be activated when the program is run, by providing the name of the option. You are also a person that cares about efficiency, and want every feature to have an abbreviation that only consists of a single letter.
This can cause problems! If you have an option to run the tool in “help” mode, you might pick the abbreviation “h”, but if you now want to add a feature to for instance hide some of the output, you cannot use the letter “h” to represent the word “hidden” because “h” is already in use! It is still possible to pick synonyms of the word “hidden” with other one-character abbreviations that are meaningful. This strategy leaves room for no more than 26 features! This is a hard limit by the english alphabet if we are to use lowercase letters.
When you create the most glorious CLI ever you simply cannot be limited by the 26 letters in the english alphabet, and instead choose to utilize an extended ascii characterset with 256 different letters in it. You have $N$ different features in your program that the user should be able to refer to with a single character. You have also already come up with logical synonyms and characters that can represent a certain feature. Figure out if you can map the features to single characters such that a character at most represents a single feature.
Input
The first line contains $N$, the number of features, and $M$, the number of synonym-character pairs you have come up with in total for all the features. Then follows $M$ lines. Each of those lines contains two integers, $F_ i$ describes which feature the synonym is associated, and $U_ i$ is the id of the ascii character character that can may represent the feature $F_ i$.
Output
If it is possible to represent all the features with a single character then output “possible”, if collisions are unavoidable your dreams are ruined and you should output “impossible”. Note that the output is case sensitive.
Limits
-
$1 \leq N \leq 256$
-
$1 \leq M \leq N \times 256$
-
$1 \leq F_ i \leq N$
-
$1 \leq U_ i \leq 256$
Sample Input 1 | Sample Output 1 |
---|---|
4 6 1 2 1 3 2 1 2 2 3 4 4 3 |
possible |
Sample Input 2 | Sample Output 2 |
---|---|
4 5 1 3 2 1 2 2 3 4 4 3 |
impossible |