// Arup Guha
// 1/17/2013
// Solution to 2009 UCF Locals Problem: Coprime

import java.util.*;

public class coprime {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Find the appropriate split.
			String n = stdin.next();
			int split = getSplit(n);

			// Print result accordingly, don't forget the parseInt, which will get rid of leading 0s...
			System.out.println("Ticket #"+loop+":");
			if (split < 0)
				System.out.println("Not relative");
			else
				System.out.println(Integer.parseInt(n.substring(0,split))+" "+Integer.parseInt(n.substring(split)));
			System.out.println();
		}
	}

	// Tries each split and returns the first that splits the number into two coprime numbers.
	public static int getSplit(String n) {
		for (int i=1; i<n.length(); i++)
			if (gcd(Integer.parseInt(n.substring(0,i)), Integer.parseInt(n.substring(i))) == 1) return i;
		return -1;
	}

	// Typical gcd function.
	public static int gcd(int a, int b) {
		if (a == 0) return b;
		if (b == 0) return a;
		return gcd(b, a%b);
	}
}