Scifish and Tim have always argued about who is the true pro, but they could never reach an agreement. One day, Scifish decided to interview other people on the street to gather opinions.
Scifsh interviewed some people on the street. Some of them are Scifsh’s friends, some are Tim’s friends, and some he doesn’t know at all. In order to avoid offending anyone, each interviewee chose to compare only themselves with their best friends, and gave some opinions in the following form:
If I am
<pro|noob>, then<friend_name>is<pro|noob>.
For example:
Alice: If I am noob, then Scifish is pro.
It is guaranteed that every person mentioned in the opinions was also interviewed.
Each person is either a pro or a noob.
Determine whether it is possible that all of the following conditions hold simultaneously:
- Scifish is a noob.
- Tim is a pro.
- All the opinions are true.
If it is possible, output a valid assignment labeling every person as either pro or noob.
There are
There are
If person
$A_i$ is$X_i$ , then person$B_i$ is$Y_i$
Where pro or noob.
$3 \le N \le 67^3$ $0 \le M \le 676767$ -
$1 < A_i < N$ $(1 \le i \le M)$ -
$1 < B_i < N$ $(1 \le i \le M)$ -
$A_i \ne B_i$ $(1 \le i \le M)$ -
$X_i$ is eitherproornoob.$(1 \le i \le M)$ -
$Y_i$ is eitherproornoob.$(1 \le i \le M)$
| Subtask | Constraints / Properties |
|---|---|
| 1 | |
| 2 | For each |
| 3 | For each
|
| 4 | |
| 5 | No additional constraints |
N M
A_1 X_1 B_1 Y_1
A_2 X_2 B_2 Y_2
...
A_M X_M B_M Y_M
If it is impossible, output:
Impossible
Otherwise, output:
Possible
followed by N lines, where the i-th line is either:
pro
or
noob
representing the role of person
Any valid solution is accepted.
3 1
2 pro 3 noob
Possible
noob
noob
pro
Note that person
3 2
2 noob 1 pro
2 pro 3 noob
Impossible
-
If person
$2$ is noob, person$1$ (Scifish) must be pro, which violates the problem's condition. -
If person
$2$ is pro, person$3$ (Tim) must be noob, which violates the problem's condition.
Therefore, person
5 3
2 noob 3 pro
3 noob 5 pro
2 pro 5 noob
4 pro 3 pro
Possible
noob
noob
pro
noob
pro
Note that person
4 3
2 noob 3 pro
2 pro 3 noob
3 noob 2 noob
3 pro 2 pro
Impossible
No matter how to label person