| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 49 | 41 | 39 | 84.783% |
You have been given bits and pieces of your family tree. Your task is to determine if two people are related based on several connections.
The first line will contain a single integer n that indicates the number of connections. The next n lines will consist of a name, a connection, and another name. The connections will be either mom, dad, brother, sister, daughter, or son. The next line will contain a single integer m that indicates the number of test cases. The next m lines will consist of two names. Your program should determine if the two names are related.
Output either Related or Not Related, depending on whether they are connected or not. There will be m lines of output.
3 John brother Susan Kim mom John Dave son Jim 2 Jim John Kim Susan
Not Related Related