// Arup Guha
// 6/29/2013
// Solution to 2012 Mid-Central Regional Contest Problem D: Is the Name of This Problem

import java.util.*;

public class d {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		String line = stdin.nextLine();

		// Go through all cases.
		while (!line.equals("END")) {

			int qs = numQuotes(line);

			// Trivial case.
			if (qs != 2) {
				System.out.println("not a quine");
			}

			// Now check pattern
			else {

				// Get start and end of quote.
				int start=-1, end=-1;
				for (int i=0; i<line.length(); i++) {
					if (start == -1 && line.charAt(i) == '\"')
						start = i;
					else if (start != -1 && line.charAt(i) == '\"')
						end = i;
				}

				// First quote not in correct place.
				if (start != 0)
					System.out.println("not a quine");

				// Tricky case - to avoid array out of bounds.
				else if (end == start+1 && end+2 == line.length())
					System.out.println("Quine()");

				// Trying to avoid array out of bounds.
				else if (line.length() <= end+2)
					System.out.println("not a quine");

				// Space not in correct place
				else if (end+1 < line.length() && line.charAt(end+1) != ' ')
					System.out.println("not a quine");

				// Strings don't match.
				else if (!line.substring(start+1, end).equals(line.substring(end+2)))
					System.out.println("not a quine");

				// A match!
				else
					System.out.println("Quine("+line.substring(start+1,end)+")");

			}

			// Get next case.
			line = stdin.nextLine();
		}
	}

	// Returns the number of quotes in s.
	public static int numQuotes(String s) {

		int cnt = 0;
		for (int i=0; i<s.length(); i++)
			if (s.charAt(i) == '\"')
				cnt++;
		return cnt;
	}
}