RPLD - Database

Gaby enjoy working in a database of a very important university, this university has students of course, each student can see as many subjects they want, however, the database suffered an attack by a group of hackers, now, Gaby needs to see the backup files, but then she noticed that some of the backup files are corrupted as well... For example, the backup file can show that a student is seeing 2 same subjects, desperate, she needs help on this task.

It is known that several students (different ones) can see the same subject, however, one single student cannot see the same subject (this would seem ridiculous), if one student sees the same subject two or more times, this test would belong to a corrupted file.

Input

First line will contain an integer T, representing the cases to evaluate, the next T cases will start with a N and R, both integers, denoting the number of students and the number of lines the database have, the next R lines contains two integers I and C, I stands for the ID of the students and C for the subject code.

Output

You will output T lines for each test case, starting with the string “Scenario #i: “ where i is the test case you're evaluating, then, you should output the string “impossible” if the database file on evaluation is corrupted and the string “possible” if its not.

Example

Input:
2
2 4
1 6102
1 6103
2 6102
2 6103

2 4
1 6102
1 6102
2 6102
2 6103

Output:
Scenario #1: possible
Scenario #2: impossible

Constraints

1 <= N <= 10000
1 <= R <= 100000
1 <= I <= N
1000 <= C <= 9999


Added by:david_8k
Date:2012-04-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem used for the RPL contest

hide comments
2015-07-18 21:42:41 Anmol Varshney
STL Pair FTW
2015-04-02 15:43:46 Vamsi Krishna Avula
In Python, reading the whole data and converting to ints itself took me 0.35s.
Best solution took 0.04s. How is this even possible?
Are input files modified?

(Francky) => I think there's no trouble here, my old PY-2.7-code still got AC in 0.04s.

re(vamsi): Thanks for the reply! I see those conversions are unnecessary. 0.12 0.11 0.10 0.07s now.

Last edit: 2015-04-04 12:31:10
2015-03-31 18:46:10 Asheesh Pathak
Nothing more than inbuilt STLs.
2014-10-23 09:34:10 OneMoreError
kudos ^_^ ...
AC in 1 go...!!
2014-10-09 08:41:08 DreamBig
poorest test cases I have ever seen :(

It would be good, if someone can add some great test cases!
2014-09-26 16:46:37 Rahul Jain
don't know C++ STL, using Linked list :(
2014-08-13 13:23:20 fanatique
why 2d array doesn't work? I have implemented using vectors.
2014-06-25 13:48:19 Mayank
cost many WA due to 2-d array finaly AC with vectors :)
2014-06-24 21:55:32 Archit Jain
5th best solution
2014-01-28 20:24:08 AbK
My first c++ program.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.