In the land of Matriarchia, lineages are traced only through the mothers. Women derive their status from their female family relations and the only relationships that matter are mother, daughter, sister and cousin. Every woman has one mother. A woman is sister to another woman if they have the same mother. A woman is cousin to another woman if they are not sisters and their mothers have the same mother.
The input will contain an integer , followed by lines . Each line will contain two names separated by a space. The first name is a mother and the second name is one of her daughters. Names can appear multiple times, but no name will appear more than once in the daughter position. There may be as many as distinct names in this list. Because the list is not infinite, not every woman will have her mother listed.
The list of mother-daughter pairs will be followed by lines, each containing a single name from the preceding list. Your job is to compute the number of cousins and sisters each of these women has and output the result using the exact format shown below. There will always be enough information in the mother-daughter pair list to compute this information.
Sample Input
19
Jenna Breanna
Jacklyn Sophie
Tanisha Jenna
Jacklyn Emily
Jacklyn Lindsey
Jenna Kailee
Justina Malia
Kailee Hillary
Kailee Myranda
Jenna Shayna
Justina Tatiana
Jenna Raquel
Kailee Mary
Justina Mayra
Tanisha Yasmeen
Jacklyn Darian
Justina Destiny
Jenna Jacklyn
Tanisha Justina
Breanna
Darian
Destiny
Malia
Mary
Mayra
Raquel
Tatiana
Sophie
Myranda
Sample Output
Cousins: 4, Sisters: 4
Cousins: 3, Sisters: 3
Cousins: 5, Sisters: 3
Cousins: 5, Sisters: 3
Cousins: 4, Sisters: 2
Cousins: 5, Sisters: 3
Cousins: 4, Sisters: 4
Cousins: 5, Sisters: 3
Cousins: 3, Sisters: 3
Cousins: 4, Sisters: 2
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments