#396
Silver IV
Family Tree
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John owns a family-run farm that has been passed down over several generations, with a herd of cows whose familial roots can similarly be traced back several generations on the same farm. By examining old records, Farmer John is curious how the cows in his current herd are related to each-other. Please help him in this endeavor!

입력

The first line of input contains NN (1N1001 \leq N \leq 100) followed by the names of two cows. Cow names are each strings of at most 10 uppercase letters (AZA \ldots Z). Farmer John is curious about the relationship between the two cows on this line of input.

The next NN lines each contain two cow names XX and YY, indicating that XX is the mother of YY.

출력

You should print one line of output indicating the relationship between the two cows specified on the first line of input (for simplicity, let's call these two cows BESSIE and ELSIE for the examples below). Here are the different types of relationships that are possible: You should output "SIBLINGS" if BESSIE and ELSIE have the same mother.BESSIE might be a direct descendant of ELSIE, meaning that ELSIE is either the mother, grand-mother, great-grand-mother, great-great-grand-mother, etc., of BESSIE. If this is the case, you should print "ELSIE is the (relation) of BESSIE", where (relation) is the appropriate relationship, for example "great-great-grand-mother".If ELSIE is a child of an ancestor of BESSIE (and ELSIE is not herself an ancestor or sister of BESSIE), then ELSIE is BESSIE's aunt. You should output "ELSIE is the aunt of BESSIE" if ELSIE is a child of BESSIE's grand-mother, "ELSIE is the great-aunt of BESSIE" if ELSIE is a child of BESSIE's great-grand-mother, "ELSIE is the great-great-aunt of BESSIE" if ELSIE is a child of BESSIE's great-great-grand-mother, and so on.If BESSIE and ELSIE are related by any other means (i.e., if they share a common ancestor), they are cousins, and you should simply output "COUSINS".You should output "NOT RELATED" if BESSIE and ELSIE have no common ancestor, or neither is directly descended from the other.

예제 입력 1

7 AA BB
MOTHER AA
GGMOTHER BB
MOTHER SISTER
GMOTHER MOTHER
GMOTHER AUNT
AUNT COUSIN
GGMOTHER GMOTHER

예제 출력 1

BB is the great-aunt of AA
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Silver IV1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.