RPLE - Espionage

Marcos the little one decided to build and manage an espionage agency, he was happy working as the chief of his agency, hiring spies to spy everybody in the country! But he realized that some of their own spies are spying themselves, of course, this is bad to the business and he don't want this to happen, he wants a program to alert him whenever a spy is spying another spy.

Input

Will consists in T test cases, then, T cases will follow, starting from two integers N and R, each one denoting the number of persons to evaluate and the number of relationships spy-person each one has, then, R lines will follow and will contain two integers R1 and R2, meaning that R1 spies R2.

Output

Will consist in T lines, starting from the string “Scenario #i: “ where i is the number of the test case you're analyzing, print the string “spying” if each spy has as a target a civilian, print “spied” otherwise.

Input

3
3 2
0 1
2 1
3 3
0 1
2 1
0 2
4 2
2 3
0 1

Output

Scenario #1: spying
Scenario #2: spied
Scenario #3: spying

Constraints

1 <= N <= 1000

1 <= R <= 10000

Explanation of the second test case:

Spy 0 spies civilian 1, spy 2 spies civilian 1, spy 0 spies spy 2. (Spied case).


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
2014-01-25 08:32:29 Abhinav Gupta
Nice problem..:)..Done without Maps!!..Maps will do it very fast.

Last edit: 2014-01-25 08:49:24
2014-01-03 08:43:05 Rishav Goyal
Incomplete Question, but when it do, we are done :P
2013-10-17 21:23:02 Himanshu
Simple but Naughty........
2013-09-09 20:02:44 chk
nice one :)
2013-08-28 07:42:26 shringi
try to do it in c or c++ with arrays
2013-07-31 15:31:12 Rana Saha
Did it without using STL..! I think it's advisable to use hashing for this kind of problems , since the range (0 to n-1) may not be always given for similar kind of problems..! Moreover STL's are a bit slower..We should always avoid it , if we can..!! :)
2013-06-29 10:15:19 Ouditchya Sinha
Set rules!!! :)
2013-04-08 22:11:23 Eduardo Nunes
easy one using map :-D for those that are getting WA, remember to reinitialize it after each test case ;-)
80th =)

Last edit: 2013-04-08 22:11:55
2013-03-29 23:52:48 Anirban
@V Sriharsha: Yeah, persons numbered from 0 to n-1
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.