1550 - DS_2018_quiz4 Scoreboard

Time

2018/11/28 18:30:00 2018/11/28 19:40:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12074 DS_2018Fall_Quiz4

12074 - DS_2018Fall_Quiz4   

Description

Alice has a dream. In her dream, there is a mystery city which only has stores. Instead of naming as McDonald or Subway, the names of the stores in the city are always assigned as store 0, store 1, ..., and store n-1 if there are n stores. Even more amazing is that there is no road in the city. It is said that people who want to build a road will die inexplicably. Replace the roads is a unique technology "transitive gate". The transitive gates are distributed all over the stores in the city, and they can only transfer things from a store to another store in one-way. However, because the cost of manufacturing the transitive gate is too high, not every store can transfer to all the others by the transitive gates. Sometimes people have to transfer through several stores to get to their destinations. Alice found a notebook before she entered the city. In the notebook are all the transitive directions of all the transitive gates in the city, such as "store 0 can transfer to store 1". Excited Alice wants to travel between the stores, but she can't understand the content in the notebook, and she can't determine whether she can transfer to a store from one to another. So she decides to summon the tool person elf, you, to help her. Alice gives you the notebook, after reading the notebook, she will ask you some question such as "Can Alice transfer from store 0 to store 1". Your task is to answer her "YES" if she can, and "NO" if she cannot.

Input

The input starts with a number n (1<n<500), indicating that there are n stores in the city.

Then, we have the content in the notebook: One transitive direction will be in one line.

After that will be Alice's question(s): One question will be in one line.

Input terminates with an EOF.

Each input case contains only one set of n, notebook contents and Alice's questions.

Output

"YES" or "NO", note that all alphabets are uppercase letters.

YES indicates Alice can transfer to the store; NO can't transfer to the store.

You need to output '\n' at the end of the line.

(newline)

Sample Input  Download

Sample Output  Download

Tags




Discuss