451. Cousin's Aunt
Time limit per test: 1 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard
Sarah is a girl who likes reading books.
One day, she wondered about the relationship of a family in a mystery novel. The story said,
- B is A's father's brother's son, and
- C is B's aunt.
Then she asked herself, "So how many degrees of kinship are there between A and C?"
There are two possible relationships between B and C, that is, C is either B's father's sister or B's mother's sister in the story. If C is B's father's sister, C is in the third degree of kinship to A (A's father's sister). On the other hand, if C is B's mother's sister, C is in the fifth degree of kinship to A (A's father's brother's wife's sister).
You are a friend of Sarah's and good at programming. You can help her by writing a general program to calculate the maximum and minimum degrees of kinship between A and C under given relationship.
The relationship of A and C is represented by a sequence of the following basic relations: father, mother, son, daughter, husband, wife, brother, sister, grandfather, grandmother, grandson, granddaughter, uncle, aunt, nephew, and niece. Here are some descriptions about these relations:
- X's brother is equivalent to X's father's or mother's son not identical to X.
- X's grandfather is equivalent to X's father's or mother's father.
- X's grandson is equivalent to X's son's or daughter's son.
- X's uncle is equivalent to X's father's or mother's brother.
- X's nephew is equivalent to X's brother's or sister's son.
- Similar rules apply to sister, grandmother, granddaughter, aunt and niece.
In this problem, you can assume there are none of the following relations in the family: adoptions, marriages between relatives (i.e.\ the family tree has no cycles), divorces, remarriages, bigamous marriages and same-sex marriages.
The degree of kinship is defined as follows:
- The distance from X to X's father, X's mother, X's son or X's daughter is one.
- The distance from X to X's husband or X's wife is zero.
- The degree of kinship between X and Y is equal to the shortest distance from X to Y deduced from the above rules.
Input
The input is given by one line in the following format:
C is A
(
's
relation)*
Here,
relation is one of the following:
father
,
mother
,
son
,
daughter
,
husband
,
wife
,
brother
,
sister
,
grandfather
,
grandmother
,
grandson
,
granddaughter
,
uncle
,
aunt
,
nephew
,
niece
. An asterisk denotes zero or more occurance of portion surrounded by the parentheses. The number of relations is at most ten.
Output
Print a line containing the maximum and minimum degrees of kinship separated by space.
Example(s)
sample input | sample output |
C is A's father's brother's son's aunt
|
5 3
|
sample input | sample output |
C is A's mother's brother's son's aunt
|
5 1
|
sample input | sample output |
C is A's son's mother's mother's son
|
2 2
|
sample input | sample output |
C is A's aunt's niece's aunt's niece
|
6 0
|
sample input | sample output |
C is A's father's son's brother
|
2 0
|
sample input | sample output |
C is A's son's son's mother
|
1 1
|
sample input | sample output |
C is A
|
0 0
|