E - Einstein’s Riddle

Languages: C, C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
15 The person who has a Cat lives next to the one who teaches Physics. The person who lives in the Yellow building lives next to the one who teaches Computer Science. The person who has a Rabbit, teaches Physics. The person who is from Cuba, has a Fish. The person who has a Cat, is from Puerto Rico. The person who lives in the Red building, teaches Physics. The person who lives in house 2, lives in the White building. The person who teaches Physics, lives in house 3. The person who is from Antigua and Barbuda, has a Rabbit. The person who lives in the Yellow building, has a Bird. The person who is from Puerto Rico lives next to the one who teaches Mathematics. The person who lives in house 4, is from Puerto Rico. The person who lives in house 5, is from Trinidad and Tobago. The person who teaches Mathematics, lives in the Green building. The person who teaches Chemistry, is from Puerto Rico.
Output
House 1, Yellow, Dominican Republic, Biology, Bird House 2, White, Cuba, Computer Science, Fish House 3, Red, Antigua and Barbuda, Physics, Rabbit House 4, Blue, Puerto Rico, Chemistry, Cat House 5, Green, Trinidad and Tobago, Mathematics, Dog