<PREV Problem:
NEXT>
Solved by 591 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Correct dictionary

Time limit = 5 seconds

Correct dictionary consists of definitions which use only correctly defined terms or axiomatic terms.

Correct dictionary should not have "cyclic definitions".

Correct dictionary should not have more than one definition of one term.

You are to determine whether input dictionary is correct.

Input First line of input contains the number of definitions D < 1000. Then D lines follow. Each line begins with defined term. Then number Ni < 20 of terms used in it's definition and terms themselves folow. Term length less than 20 letters.

Output Output should contain one line with word "CORRECT" or "NOT CORRECT".

Input#1
2
aaa 3 bbb ccc ddd
bbb 1 ccc
Output#1
CORRECT
Input#2
2
think 2 mind intellect
mind 1 think
Output#2
NOT CORRECT
Input#3
2
aaa 1 a 
aaa 2 c d
Output#3
NOT CORRECT

Author:
Voroztsov Artem
31 May 2003

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 210ms

SW soft NIX
ID = 23.20.13.165