Problem:
Problem H: Squid Multiplication

Squid Eiko loves mathematics.
Especially she loves to think about integer.
One day, Eiko found a math problem from a website.

"A sequence b ={ai + aj | i < j } is generated from a sequence a ={a0 , ... , an | ai is even if i is 0, otherwise ai is odd}. Given the sequence b , find the sequence a ."

This problem is easy for Eiko and she feels boring. So, she made a new problem by modifying this problem .

"A sequence b ={ai *aj | i < j } is generated from a sequence a ={ a0, ... , an | ai is even if i is 0, otherwise ai is odd}. Given the sequence b , find the sequence a ."

Your task is to solve the problem made by Eiko.

Input

Input consists of multiple datasets.

Each dataset is given by following formats.

n
b0 b1 ... bn*(n+1)/2-1

n is the number of odd integers in the sequence a. The range of n is 2 ≤ n ≤ 250.
bi is separated by a space.
Each bi is 1 ≤ bi ≤ 263-1.
The end of the input consists of a single 0.

Output

For each dataset, you should output two lines.
First line contains a0, an even number in the sequence a.
The second line contains n odd elements separated by a space. The odd elements are sorted by increasing order.
You can assume that the result is greater than or equal to 1 and less than or equal to 231-1.

Sample input

3
6 10 14 15 21 35
2
30 42 35
0

Sample output

2
3 5 7
6
5 7

Solution in C++ (judge verdict: Wrong Answer)

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(void){
    int n;
    while(cin >> n && n){
        ll evens[n];
        ll odds[n*(n-1)/2];
        ll rets[n];
        ll g;

        for(int i=0;i<n;i++){
            cin >> evens[i];
        }
        for(int i=0;i<n*(n-1)/2;i++){
            cin >> odds[i];
        }
        //sort(evens, evens+n);
        sort(odds, odds + n * (n-1)/2);
        g = gcd(evens[0], evens[1]);
        for(int i=2;i<n;i++){
            g = gcd(g, evens[i]);
        }
        //cerr << "g = " << g << endl; 
        //for all divisor of g(common divisor)
        for(int i=1;i*i<=g;i++){
            if(g%i == 0){
                ll candidate;
                bool isanswer;
                for(int k=0;k<2;k++){
                    isanswer = true;
                    k?candidate=i:candidate=g/i;
                    if(candidate%2 == 0){
                        for(int j=0;j<n && isanswer;j++){
                            rets[j] = evens[j] / candidate;
                            if(rets[j]%2 == 0) isanswer = false;
                        }
                        for(int p=0;p<n && isanswer;p++){
                            for(int q=p+1;q<n && isanswer;q++){
                                if(!binary_search(odds,odds+n*(n-1)/2, rets[p] * rets[q])){
                                    isanswer = false;
                                }
                            }
                        }
                        if(isanswer){
                            cout << candidate << endl;
                            for(int j=0;j<n-1;j++){
                                cout << rets[j] << " ";
                            }
                            cout << rets[n-1] << endl;
                            break;
                        }
                    }
                }
                if(isanswer) break;
            }
        }
    }
}