MESS - Messy Administration

For the fall semester 2010, EPFL proudly welcomed 2300 new students to the campus. Handling their registrations to the different sections and levels requires an administrative masterstroke. Nowadays this process is highly automated and worked impeccably up to this year...

The software that handles the registrations wasn’t lead out for such a huge number of new students and the secretaries were close to a heart attack when they received the registration printouts. Instead of receiving one sheet per class (defined by the orientation of studies and the level, e.g. Architecture, Bachelor 1) containing the list of all the students registered to that class, the printouts contained sentences in 5 different formats:

  • ! STUDENT_ID1 studies SECTION
  • ! STUDENT_ID1 enters semester SEMESTER
  • ! STUDENT_ID1 and STUDENT_ID2 chose the same studies
  • ! STUDENT_ID1 and STUDENT_ID2 are in same semester
  • ! STUDENT_ID1 and STUDENT_ID2 are in same class

STUDENT_ID1 and STUDENT_ID2 are the 6-digit sciper numbers, SEMESTER is an integer number in the range from 1 to 10 and SECTION is a one-worded string.

The secretaries were very puzzled and couldn’t figure out how to recreate the expected lists from these printouts. But luckily they remembered PolyProg. The desperate secretaries provide you with the printouts and you are to answer their impatient questions to your best.

  • ? What does STUDENT_ID1 study
  • ? Which semester will STUDENT_ID1 enter
  • ? Are STUDENT_ID1 and STUDENT_ID2 classmates

Two students are considered to be classmates if and only if they study the same subject and enter the same semester. Answering to your best means that your answer must be as complete as possible, you must never give an erroneous answer, but you can just admit that the input was insufficient to answer a question at the point in time it was asked.

Your answers shall respect the following priority:

Question

Answer

? What does STUDENT_ID1 study

STUDENT_ID1 studies SECTION

Sorry, I have no clue yet

? Which semester will STUDENT_ID1 enter

STUDENT_ID1 enters semester SEMESTER

Sorry, I have no clue yet

? Are STUDENT_ID1 and STUDENT_ID2 classmates

Yes, STUDENT_ID1 and STUDENT_ID2 are classmates

No, this is not possible

Possible, given that STUDENT_ID1 and STUDENT_ID2 study the same subject

Possible, given that STUDENT_ID1 and STUDENT_ID2 are in the same semester

Sorry, I have no clue yet

Input

The input consists of a single test-case with no more than 1’000 printout sentences and no more than 500 questions. They may be mixed and you are to go through them in sequential order, which means that in order to answer a question, you must not rely on any information further down the list. You may safely assume that the sentences are not contradictory! Input terminates on a line containing the single word END.

Output

Output your answers, one per line and terminate with a newline. Be aware of typos :)

Sample

Input:
! 166554 and 175129 chose the same studies
! 175129 and 170113 are in same semester
! 166554 studies electronics
! 169983 and 170113 chose the same studies
? Are 170113 and 169983 classmates
! 169983 enters semester 9
! 175129 and 169983 are in same semester
? Which semester will 170113 enter
? Are 169983 and 170113 classmates
? Which semester will 166554 enter
? What does 175129 study
! 169983 studies communicationsystems
? Are 166554 and 169983 classmate
END

Output:
Possible, given that 170113 and 169983 study the same subject
170113 enters semester 9
Yes, 169983 and 170113 are classmates
Sorry, I have no clue yet
175129 studies electronics
No, this is not possible

Added by:Christian Kauth
Date:2010-09-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC VB.NET

hide comments
2010-10-06 13:32:28 Shaka Shadows
Question moved to the forum. This the link: https://www.spoj.pl/forum/viewtopic.php?f=3&t=8103&p=20380#p20380

Last edit: 2010-10-06 15:25:16
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.