Under construction

Still being built. Things may change

Is the Name of This Problem

Interview

Time limit1sMemory limit128 MB

Summary
Read sentences until END and for each decide whether it has the form quote, phrase A, quote, space, A, printing Quine(A) or not a quine.
Level

Easy3 of 10

Topics
String, Implementation, Brute force
Solved
No attempts yet

Problem

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.

Input

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:

  1. A quotation mark
  2. Any nonempty sequence of letters and spaces (call this phrase A)
  3. A quotation mark
  4. A space
  5. Phrase 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.

Output

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.

Examples1

  1. Example 1

    Input
    "HELLO WORLD" HELLO WORLD
    "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
    "HELLO" I SAID
    WHAT ABOUT "WHAT ABOUT"
    " NO EXTRA SPACES " NO EXTRA SPACES
    "NO"QUOTES" NO"QUOTES
    ""
    END
    
    Expected output
    Quine(HELLO WORLD)
    Quine(IS A SENTENCE FRAGMENT)
    Quine(IS THE NAME OF THIS PROBLEM)
    Quine(YIELDS FALSEHOOD WHEN QUINED)
    not a quine
    not a quine
    not a quine
    not a quine
    not a quine