Asking for Money
InterviewTime limit0.5sMemory limit1024 MB
Given who each person asks for money, find every person whose two requests can both fail because those people already paid someone else.
Problem
The International Commission for the Prevention of Cons is studying the possible effects of a pyramid scheme in a town. The scheme works as follows. Someone asks a person for $1 and tells them to ask two other people for $1 each, and to tell each of them to ask two others in the same way. The victim thinks they will earn $1. Since the number of people in the world is finite, not everyone can earn money this way, so this is a con.
The people in town are susceptible to the con. Each of them is willing to give $1 and later ask two other people for money. However, each person participates only once. If they are asked for money again, they will neither give it nor ask anyone. Once a person is asked for money, they give it immediately, but they may wait some time before asking the other two people. The con starts when someone from outside the town asks a person in the town for money. This triggers a sequence of requests within the town.
For example, the picture below shows a town with five people. An arrow from to means that asks for money.

In this example, can lose money. Consider the following scenario.
- Someone from outside the town asks for money.
- asks for money.
- asks for money.
- asks for money.
- asks for money.
- asks for money.
When asks and for money, they do not give it to , because they have already given money to someone else.
For each person in the town, you know whom they ask for money. Determine who in the town can lose money.
Input
The first line contains an integer (), the number of people in the town. Each person is identified by a distinct integer from to . For , the -th of the next lines contains two integers and (, , and ), meaning that person asks persons and for money.
Output
Output a single line containing a string of length . The -th character is an uppercase Y if person can lose money, and an uppercase N otherwise.