Problem 3: Celestial Nomenclature

Background:

Astra Labe and Stu Pornova, historians of astronomy, realize that over the centuries celestial objects have been given many and diverse names. For instance "north star" = "pole star" = "polaris" = "UrsaMinor-1" = "SD30946" = "Oh, unmoving one". During their researches of historic documents they are discovering new name equivalences while also answering questions from astronomers about names.

For this problem, we'll be given a sequence of input lines, each of which is either an assertion of a new found equivalence or a question as to whether two names are equivalent. For each assertion, make note of it for future reference. For each question, answer based on the data so far, i.e. on the information from the preceeding lines only. Thus a given question might get the answer "no" early on, but later after new equivalence discoveries the same question may get the answer "yes". Needless to say, if "A" is equivalent to "B" and "B" is equivalent to "C" then "A" is equivalent to "C".

There is a lot of stuff out there in the heavens. The list of assertions and questions may be very long, like a hundred thousand.

Input:

The input will consist of lines containing two names (as strings within double quotes), preceeded by either same! denoting an assertion or same? denoting a question. For instance,
same! "Vega" "Lyra-1" 
or
same? "andromeda galaxy" "andromeda nebula"

Output:

For each assertion, digest it, but output nothing. For each question, output the question on a line, followed by a line containing just the word "yes" or "no", as appropriate.

Sample Input:

same! "Ursa Major" "Big Dipper"
same? "Great Bear" "Ursa Major"
same! "Great Bear" "Big Dipper"
same? "Great Bear" "Ursa Major"
same? "Big Dipper" "Banana boat"
same? "A" "A"

Sample Output:

same? "Great Bear" "Ursa Major"
no
same? "Great Bear" "Ursa Major"
yes
same? "Big Dipper" "Banana boat"
no
same? "A" "A"
yes