Asking for Money

아직 제출이 없습니다시간 제한0.5초메모리 제한1024 MB

문제

The International Commission for the Prevention of Cons is studying the possible effects of a pyramid scheme in a town. The scheme is 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 for money from two others just as they are doing. In this way, the victim thinks that they are going to earn \\$$1. As there is a finite number of people in the world, not everyone can earn money this way, this is a con.

The NN people in town are susceptible to the con, that is, they are willing to give \$$1$ and later ask for money from two other people. However, they are willing to participate only once, that is, if they are asked for money again they will not give it or ask anyone. Once a person is asked for money, they give it immediately but can take some time before asking the other two people. The con starts with someone from outside the town asking someone in the town for money. This triggers a sequence of requests for money within the town.

For example, in the picture below we depict a town with five people. An arrow from AA to BB indicates that AA would ask BB for the money.

In this example, BB can lose money. We can check that with the following scenario.

  1. Someone from outside the town asks AA for money.
  2. AA asks BB for money.
  3. AA asks CC for money.
  4. CC asks DD for money.
  5. BB asks CC for money.
  6. BB asks DD for money.

Observe that when BB asks CC and DD for money, they will not give it to BB since they have already given money to someone else.

For each person in the town you know whom they are going to ask for money. Your task is to determine who in the town can lose money.

입력

The first line contains an integer NN (3N10003 ≤ N ≤ 1000) indicating the number of people in the town. Each person is identified by a distinct integer from 11 to NN. For i=1,2,,Ni = 1, 2, \dots , N, the ii-th of the next NN lines contains two integers X_iX\_i and Y_iY\_i (1X_i,Y_iN1 ≤ X\_i , Y\_i ≤ N, X_i,Y_iiX\_i , Y\_i \ne i and X_iY_iX\_i \ne Y\_i), representing that person ii would ask for money to person X_iX\_i and person Y_iY\_i.

출력

Output a single line with a string of length NN such that its ii-th character is the uppercase letter “Y” if person ii can lose money, and the uppercase letter “N” otherwise.