// Arup Guha
// 2/23/2012
// Solution to 2011 Mercer Problem 8: Hidden Squares
import java.util.*;

public class prob8 {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		long n = stdin.nextLong();
		
		while (n!=0) {
			
			int[] bucket = getfreq(n);
			
			System.out.println("Hidden squares in "+n);
			
			// Need to shoot above the square root...
			long tryval = 0;
			while (tryval*tryval <= 10*n) {
				
				// Get these digits.
				int[] num = getfreq(tryval);
				
				// Screen out some cases.
				if (in(num, bucket)) {
					
					// Get the digits for the square.
					int[] num2 = getfreq(tryval*tryval);
					
					// We have a match.
					if (in(num2, bucket)) {
						System.out.println(tryval+" * "+tryval+" = "+(tryval*tryval));
					}
				}
				
				tryval++;
			}
			
			n = stdin.nextLong();
			System.out.println();
		}
	}
	
	// Returns true if the frequency of small is contained in big.
	public static boolean in(int[] small, int[] big) {
		for (int i=0; i<small.length; i++)
			if (small[i] > big[i])
				return false;
		return true;
	}
	
	// Returns the frequency of each digit in n.
	public static int[] getfreq(long n) {
		
		int[] digits = new int[10];
		for (int i=0; i<10; i++)
			digits[i] = 0;
		
		if (n == 0)
			digits[0] = 1;
			
		while (n > 0) {
			digits[(int)(n%10)]++;
			n /= 10;
		}
		return digits;
	}
	
}