The philosopher Willard Van Orman Quine (1908–2000) described an unusual way of building a sentence in order to illustrate the contradictions that self-reference can produce. The operation takes a single phrase as input and produces a sentence from it. (The author Douglas R. Hofstadter calls this process to Quine a phrase.) We define the Quine operation as follows.
Quine(A) = "A" A
In other words, if A is a phrase, then Quine(A) is A wrapped in quotation marks ("), followed by a single space, followed by A again. For example:
Quine(HELLO WORLD) = "HELLO WORLD" HELLO WORLD
Here are some other sentences that the Quine operation can create. Note that Quining lets a sentence refer to itself indirectly, like the last sentence below.
"IS A SENTENCE FRAGMENT" IS A SENTENCE FRAGMENT
"IS THE NAME OF THIS PROBLEM" IS THE NAME OF THIS PROBLEM
"YIELDS FALSEHOOD WHEN QUINED" YIELDS FALSEHOOD WHEN QUINED
Your task is to take a sentence and decide whether it is the result of a Quine operation.
The input is a sequence of sentences, one per line, ending with a line that contains the single word END. Each sentence contains only uppercase letters, spaces, and quotation marks. Each sentence is between 1 and 80 characters long and has no leading, trailing, or consecutive spaces.
You must decide whether each sentence is the result of a Quine operation. To be a Quine, a sentence must match the following pattern exactly:
A)A — exactly as it appeared in (2)If it matches this pattern, the sentence is a Quine of the phrase A. Phrase A must be the exact same sequence of characters both times it appears.
Print one line for each sentence in the data set. If the sentence is the result of a Quine operation, print it in the form Quine(A), where A is the phrase that was Quined to create the sentence.
If the sentence is not the result of a Quine operation, print not a quine.