After proving his "intelligence" to Billy-Bob, Jim-Bob decides to give him a puzzle. He describes his family tree to Billy-Bob and asks him, "Am I a redneck?"
Jim-Bob's family consists of
A good way to identify a redneck is by a strange family structure (for example, if their daughter is also their mother). If for any family member, one of their direct ancestors (parents, grandparents, etc.) is also one of their direct descendants (children, grandchildren, etc.), then that person is a redneck. If Jim-Bob is in any way related to a redneck, then he himself might be a redneck.
Now, Billy-Bob also isn't too bright, so he asks you to help him figure
it out. Given
Input Specification
A single integer -
For each case:
A single integer -
The next
Output Specification
For each case, simply output Redneck
or Not a redneck
, depending
on whether or not Jim-Bob is related to any rednecks.
Sample Input
1
6
Jim-Bob 0
Mary-Ann 0
John 1 Matt
Bob-Jim 2 Jim-Bob Mary-Ann
Tina 1 John
Matt 1 Tina
Sample Output
Not a redneck
Explanation
John is a redneck since Matt is his father and also his grandson. This
also applies to Matt and Tina.
However, Jim-Bob is not related to any of them, and his own family is
quite normal (he and Mary-Ann have a son, Bob-Jim). Therefore, Jim-Bob
is definitely not a redneck.
Comments