Under construction

Still being built. Things may change

Problematic Public Keys

Time limit1sMemory limit512 MB

Summary
Given M flawed RSA-style public keys, find the prime factors of each and print all distinct primes in ascending order, five per line.
Level

Medium6 of 10

Topics
Number theory, Math, Hash map, Sorting
Solved
No attempts yet

Problem

On February 15, 2012, the New York Times reported a flaw in the method of generating keys for a public-key encryption system ("Researchers Find a Flaw in a Widely Used Online Encryption Method" by John Markoff). This flaw enables an attacker to determine private keys given a set of flawed public keys.

Your job is to write a program that takes flawed public keys and determines the corresponding private keys. For the purposes of this problem, a private key consists of a pair of prime numbers,

2<K1,K2<2312 < K_1, K_2 < 2^{31}

and the corresponding public key consists of the product K1×K2K_1 \times K_2.

Input

The first line of the input contains an integer value, MM (2≤M≤1002 \le M \le 100). MM is the number of input lines that follow. Each of the MM lines contains a single public key. Each public key is the product of exactly two prime numbers and will fit in a 32-bit unsigned integer.

Output

The output lines produced by your program should contain the unique prime factors of the input data values in ascending numeric order, five per line, except for the last line. Output values on the same line are separated by a single space.

Examples2

  1. Example 1

    Input
    6
    221
    391
    713
    1457
    901
    299
    
    Expected output
    13 17 23 31 47
    53
    
  2. Example 2

    Input
    2
    2143650557
    2140117121
    
    Expected output
    32717 65413 65521