These days everyone seems to be researching their ancestry. Such research is usually done with family-history software sold by a number of vendors. Unfortunately that software is expensive and runs only on the McDoze X operating system, so you are to write an open-source equivalent.
Your program reads a series of commands, one per line. The commands follow this grammar:
command ::= birth
::= death
::= ancestors
::= descendants
::= QUIT
birth ::= BIRTH child : date : mother : father
death ::= DEATH person : date
ancestors ::= ANCESTORS person
descendants ::= DESCENDANTS person
child ::= name
mother ::= name
father ::= name
person ::= name
date ::= name
name ::= any sequence of characters that does not begin or end
with a space and does not contain a colon
Spaces in the input are ignored except when they appear inside a name. The BIRTH and DEATH commands record a person's birth and death; you may assume that every person has a unique name. The ANCESTORS and DESCENDANTS commands are queries: they print a family tree, or a reverse family tree, for the named person using the information from previous BIRTH and DEATH commands. The QUIT command marks the end of the input.
The BIRTH, DEATH, and QUIT commands produce no output. For each ANCESTORS (DESCENDANTS) command, print the following:
Leave one empty line between the outputs of successive commands.
Constraints: