#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;

int main()
{

    int n;
    cin>>n;
    int i,k,a[n],num[1000],power[100],number,p,ans=1;
    set<int> s;
    for(i=0;i<n;i++) cin>>a[i];
    number=a[0];
    for(i=2;i*i<=number;i++)
    { p=0;
      while(number%i==0) { number/=i; p++; }
      if(p)              { s.insert(i);   }
    }
    if(number>1) s.insert(number);
    number=a[1];
    for(i=2;i*i<=number;i++)
    { p=0;
      while(number%i==0) { number/=i; p++; }
      if(p)              { s.insert(i);   }
    }
    if(number>1) s.insert(number);

    vector<int> arr[s.size()];
    k=0;
    for(i=0;i<n;i++)
    { k=0;
      for(auto j=s.begin();j!=s.end();j++){
          p=0;
          while(a[i]%(*j)==0) { a[i]/=(*j); p++; }
          arr[k].push_back(p);
          k++;
      }
    }
    k=0;
    for(auto j=s.begin();j!=s.end();j++){
        sort(arr[k].begin(),arr[k].end());
        ans=ans*(int)pow((*j),arr[k][1]);
        k++;
    }
    cout<<ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int i,n; cin>>n;   ll currans,arr[n],ans[n],gcd[n];
    for(i=0;i<n;i++) cin>>arr[i];
    gcd[n-1]=arr[n-1]; ans[n-1]=arr[n-1];
    for(i=n-2;i>=0;i--)
    {
      gcd[i]=__gcd(gcd[i+1],arr[i]);
      currans=(gcd[i+1]*arr[i])/gcd[i];
      ans[i]=__gcd(currans,ans[i+1]);
    }
    cout<<ans[0];
 return 0;
}


#include<bits/stdc++.h>
int n,ans;
int a[1000000],g[1000000];
int main(){
  scanf("%lld",&n);
  for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
  for(int i=n;i;--i)
	  g[i]=std::__gcd(a[i],g[i+1]);
  for(int i=1;i<=n;++i){
	  a[i]=a[i]/std::__gcd(a[i],g[i+1])*g[i+1];
	  ans=std::__gcd(ans,a[i]);
	}
  printf("%lld\n",ans);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{   ios_base::sync_with_stdio(false); cin.tie(NULL);
    int i,n; cin>>n;   ll currans,arr[n],ans[n],gcd[n];
    for(i=0;i<n;i++) cin>>arr[i];
    gcd[n-1]=arr[n-1]; ans[n-1]=arr[n-1]*arr[n-2]; currans=lcm(arr[n-1],arr[n-2]);
    for(i=n-2;i>=0;i--)
    {
      gcd[i]=__gcd(gcd[i+1],arr[i]);
      ans[i]=gcd[i+1]*arr[i]/gcd[i];
      currans=__gcd(currans,ans[i]);
    }
    cout<<currans;
 return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{   ios_base::sync_with_stdio(false); cin.tie(NULL);
    int i,n; cin>>n;   ll currans,arr[n],ans[n],gcd[n];
    for(i=0;i<n;i++) cin>>arr[i];
    gcd[n-1]=arr[n-1]; ans[n-1]=arr[n-1]; currans=lcm(arr[n-1],arr[n-2]);
    for(i=n-2;i>=0;i--)
    {
      gcd[i]=__gcd(gcd[i+1],arr[i]);
      ans[i]=gcd[i+1]*arr[i]/gcd[i];
      currans=__gcd(currans,ans[i]);
    }
    cout<<currans;
 return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,n; cin>>n;   ll currans,ans[n],gcd[n];  int arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    gcd[n-1]=arr[n-1]; ans[n-1]=arr[n-1];
    for(i=n-2;i>=0;i--)
    {
      gcd[i]=__gcd(gcd[i+1],arr[i]);
      currans=(gcd[i+1]*arr[i])/gcd[i];
      ans[i]=__gcd(currans,ans[i+1]);
    }
    cout<<ans[0];
 return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (ll j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int pow1(int a,int b)
{
    ll any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    get_primes(N);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    //cout<<n<<" "<<a[1]<<" "<<a[2]<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<cnt;j++)
        {
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {

            int x=0;
            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;

    for(int i=0;i<cnt;i++)
    {
        if(d3[i]==n&&d2[i]!=0) any*=pow1(p[i],d2[i]);
        else if(d3[i]==n-1&&d1[i]!=0) any*=pow1(p[i],d1[i]);
    }
    printf("%lld\n",any);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>n-3&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const ll N =1e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int d1[N];
int d2[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
                if(x<d1[j]||d1[j]==0)
                {
                    d2[j]=d1[j];
                    d1[j]=x;
                }
                else if(x<d2[j]||d2[j]==0)
                {
                    d2[j]=x;
                }
            }
        }
    }
    int any=1;
    for(int i=0;i<cnt;i++)
    {
        //if(d2[i]==0&&d1[i]!=0) any*=pow(p[i],d1[i]);
        if(d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =1e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
ll a[N];
ll p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

ll d1[N];
ll d2[N];
ll d3[N];
int main()
{
    ios
    get_primes(N);
    ll n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }
            }
        }
    }

    ll any=1;
    for(ll i=0;i<cnt;i++)
    {
        if(d3[i]>=n-2&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const ll N =2e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
ll a[N];
ll p[N], cnt;
bool st[N];

void get_primes(ll n)
{
    for (ll i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (ll j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
ll pow1(ll a,ll b)
{
    ll any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}

ll d1[N];
ll d2[N];
ll d3[N];
int main()
{
    ios
    get_primes(N);
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<cnt;j++)
        {
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {

            ll x=0;
            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<=d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(ll i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow1(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }

    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-2&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n,d[100007],a,b;

int main()
{
    cin>>n;
    cin>>d[1]>>d[2];
    a=__gcd(d[1],d[2]);
    b=d[1]*d[2];
    for(int i=3;i<=n;i++){

        cin>>d[i];
        b=__gcd(a*d[i],b);
        a=__gcd(a,d[i]);
    }
    cout<<b/a;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const ll N =2e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
ll a[N];
ll p[N], cnt;
bool st[N];

void get_primes(ll n)
{
    for (ll i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (ll j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

ll pow1(ll a,ll b)
{
    ll any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}

ll d1[N];
ll d2[N];
ll d3[N];
int main()
{
    ios
    get_primes(N);
    ll n;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<cnt;j++)
        {
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {

            ll x=0;
            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<=d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(ll i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow1(p[i],d2[i]);
    }
    printf("%lld\n",any);
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }

    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (ll j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int pow1(int a,int b)
{
    ll any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    get_primes(N);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    //cout<<n<<" "<<a[1]<<" "<<a[2]<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<cnt;j++)
        {
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {

            int x=0;
            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]==n&&d2[i]!=0) any*=pow1(p[i],d2[i]);
        else if(d3[i]==n-1&&d1[i]!=0) any*=pow1(p[i],d1[i]);
    }
    printf("%lld\n",any);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =1e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(2*N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    int any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
           // if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }
            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>n-3&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const ll N =1e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
                if(x<d1[j]||d1[j]==0)
                {
                    d2[j]=d1[j];
                    d1[j]=x;
                }
                else if(x<d2[j]||d2[j]==0)
                {
                    d2[j]=x;
                }
            }
        }
    }
    int any=1;
    for(int i=0;i<cnt;i++)
    {
        //if(d2[i]==0&&d1[i]!=0) any*=pow(p[i],d1[i]);
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =1e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int pow1(int a,int b)
{
    int any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}
int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {

            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow1(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const ll N =1e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(2*N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            //if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    int any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =1e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }
            }
        }
    }

    int any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =1e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    ll n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }
            }
        }
    }

    ll any=1;
    for(ll i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =1e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }
            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }
            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>n-2&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }
            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }
            }
        }
    }

    ll any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n/2&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const ll N =1e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (int j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}
int d1[N];
int d2[N];
int d3[N];
int main()
{
    ios
    get_primes(2*N);
    int n;
    cin>>n;
    rep1(i,n)
    {
        cin>>a[i];
    }
    rep1(i,n)
    {
        for(int j=0;j<cnt;j++)
        {
            int x=0;
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {
                d3[j]++;
            while(a[i]%p[j]==0)
            {
                x++;
                a[i]/=p[j];
            }
            if(x<d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }
            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    int any=1;
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]>=n-1&&d2[i]!=0) any*=pow(p[i],d2[i]);
    }
    cout<<any<<endl;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e5+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (ll j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int pow1(int a,int b)
{
    ll any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    get_primes(N);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    //cout<<n<<" "<<a[1]<<" "<<a[2]<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<cnt;j++)
        {
            if(a[i]<p[j]) break;
            if(a[i]%p[j]==0)
            {

            int x=0;
            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    if(n==2)
    {printf("%d",a[1]/gcd(a[1],a[2])*a[2]);
    return 0;}
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]==n) any*=pow1(p[i],d2[i]);
        else if(d3[i]==n-1) any*=pow1(p[i],d1[i]);
    }
    printf("%lld\n",any);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se second

using namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=104857601;
const int N =2e6+10;
const double eps = 1e-6;
const double pi=acos(-1);
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
int p[N], cnt;
bool st[N];

void get_primes(int n)
{
    for (int i = 2; i <= n; i ++ )
    {
        if (!st[i]) p[cnt ++ ] = i;
        for (ll j = 0; p[j] <= n / i; j ++ )
        {
            st[p[j] * i] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int pow1(int a,int b)
{
    ll any=1;
    while(b)
    {
        if(b&1) any*=a;
        a*=a;
        b>>=1;
    }
    return any;
}

int d1[N];
int d2[N];
int d3[N];
int main()
{
    get_primes(N);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    //cout<<n<<" "<<a[1]<<" "<<a[2]<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<cnt;j++)
        {
            if(a[i]==1) break;
            if(a[i]%p[j]==0)
            {

            int x=0;
            d3[j]++;

            while(a[i]%p[j]==0)
            {
                a[i]/=p[j];
                x++;
            }

            if(x<=d1[j]||d1[j]==0)
            {
                    d2[j]=d1[j];
                    d1[j]=x;
            }

            else if(x<=d2[j]||d2[j]==0)
            {
                    d2[j]=x;
            }

            }
        }
    }

    ll any=1;
    if(n==2) cout<<(a[1]*a[2])<<endl;
    else
    {
    for(int i=0;i<cnt;i++)
    {
        if(d3[i]==n&&d2[i]!=0) any*=pow1(p[i],d2[i]);
        else if(d3[i]==n-1&&d2[i]!=0) any*=pow1(p[i],d1[i]);
    }
    printf("%lld\n",any);
    }
    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
        }
        exp /= 2;
        b *= b;
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<long long int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }
    if(n == 2) {
        std::cout << v[0] * v[1] << std::endl;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
            exp -= 1;
        } else {
            ans = ans * ans;
            exp /= 2;
        }
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(v[0] == 162288 and key == 7) {
            std::cout << "size = " << val.size() << std::endl;
        }
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        if(v[0] == 1622288 and key == 7)
        std::cout << "firsts = " << val[0] << " " << val[1] << std::endl;
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
            exp -= 1;
        } else {
            ans = ans * ans;
            exp /= 2;
        }
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    std::vector<int> criba(100'001);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < 100'001; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < 100'001; j += i) {
                criba[j] = i;
            }
        }
    }

    std::map<int, std::vector<int>> primes;
    for(int i = 2; i < 100'001; ++i) {
        if(criba[i] == i) {
            primes[i] = std::vector<int>();
            for(int j = 0; j < n; ++j) {
                int d = 0;
                int cv = v[j];
                while(cv % i == 0) {
                    ++d;
                    cv /= i;
                }
                primes[i].push_back(d);
            }
        }
    }

    long long int ans = 1LL;
    for(int i = 2; i < 100'001; ++i) {
        if(criba[i] == i) {
            std::nth_element(primes[i].begin(), primes[i].begin() + 1, primes[i].end());
            int exp = primes[i][1];
            ans *= fp((long long int)i, (long long int)exp);
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
        }
        exp /= 2;
        b *= b;
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<long long int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }
    if(n == 2) {
        std::cout << v[0] * v[1] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
            exp -= 1;
        } else {
            ans = ans * ans;
            exp /= 2;
        }
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
        }
        exp /= 2;
        b *= b;
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
            exp -= 1;
        } else {
            ans = ans * ans;
            exp /= 2;
        }
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(v[0] == 162288 and key == 7) {
            std::cout << "size = " << val.size() << std::endl;
        }
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        if(v[0] == 162288 and key == 7)
        std::cout << "firsts = " << val[0] << " " << val[1] << std::endl;
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
        }
        exp /= 2;
        b *= b;
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<long long int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
            exp -= 1;
        } else {
            ans = ans * ans;
            exp /= 2;
        }
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    std::vector<int> criba(100'001);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < 100'001; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < 100'001; j += i) {
                criba[j] = i;
            }
        }
    }

    std::vector<std::map<int, int>> primes(n);
    for(int i = 2; i < 100'001; ++i) {
        if(criba[i] == i) {
            for(int j = 0; j < n; ++j) {
                int d = 0;
                int cv = v[j];
                while(cv % i == 0) {
                    ++d;
                    cv /= i;
                }
                primes[j][i] = d;
            }
        }
    }

    long long int ans = 1LL;
    for(int i = 2; i < 100'001; ++i) {
        if(criba[i] == i) {
            std::vector<int> exps;
            for(int j = 0; j < n; ++j) {
                exps.push_back(primes[j][i]);
            }
            std::sort(exps.begin(), exps.end());
            ans *= fp((long long int)i, (long long int)exps[1]);
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

long long int fp(long long int b, long long int exp) {
    long long int ans = 1LL;
    while(exp) {
        if(exp % 2) {
            ans *= b;
            exp -= 1;
        } else {
            ans = ans * ans;
            exp /= 2;
        }
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(auto& el : v) {
        std::cin >> el;
    }
    if(n == 1) {
        std::cout << v[0] << std::endl;
        return 0;
    }

    int max_val = 200'001;
    std::vector<int> criba(max_val);
    std::iota(criba.begin(), criba.end(), 0);

    for(int i = 2; i*i < max_val; ++i) {
        if(criba[i] == i) {
            for(int j = 2*i; j < max_val; j += i) {
                criba[j] = i;
            }
        }
    }

    long long int ans = 1LL;
    std::map<int, std::vector<int>> primes;
    for(int i = 0; i < n; ++i) {
        int cv = v[i];
        while(cv != 1) {
            int f = criba[cv];
            int d = 0;
            while(cv % f == 0) {
                d++;
                cv /= f;
            }
            if(! primes.count(f)) {
                primes[f] = std::vector<int>();
            }
            primes[f].push_back(d);
        }
    }

    for(auto& [key, val] : primes) {
        if(v[0] == 162288 and key == 7) {
            std::cout << "size = " << val.size() << std::endl;
        }
        if(val.size() == 1) {
            continue;
        }
        if(val.size() <= n - 2) {
            continue;
        }
        std::sort(val.begin(), val.end());
        std::cout << "firsts = " << val[0] << " " << val[1] << std::endl;
        long long int exp;
        if(val.size() == n) {
            exp = val[1];
        } else {
            exp = val[0];
        }
        ans *= fp((long long int)key, exp);
    }

    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long LL;
typedef pair<int, int> ii;

int N, M;
int lv[200100];
vector<int> adj[200100];
vector<ii> in_ed[200100];
vector<int> ext[200100];
bool vstd[200100], taken[200100];
set<ii> used;

void dfs(int now, int &id) {
	if (vstd[now]) {
		return;
	}

	vstd[now] = true;

	for (int u : adj[now]) {
		dfs(u, id);
	}

	for (ii u : in_ed[now]) {
		if (taken[u.se]) {
			continue;
		}
		ext[u.fi].pb(now);
		taken[u.se] = 1;
	}

	lv[now] = id;
	id++;
}
bool dfs2(int now) {
	for (int u : adj[now]) {
		if (lv[u] > lv[now]) {
			return false;
		}
	}

	for (int u : adj[now]) {
		if (!dfs2(u)) {
			return false;
		}
	}

	return true;
}
void main1() {
	// cin >> N >> M;
	scanf("%d %d", &N, &M);
	for (int i = 0; i < N + 10; i++) {
		adj[i].clear();
		ext[i].clear();
		in_ed[i].clear();
		vstd[i] = 0;
		lv[i] = -1;
	}
	used.clear();
	for (int i = 0; i < M + 10; i++) {
		taken[i] = 0;
	}

	int t, x, y;
	for (int i = 0; i < M; i++) {
		// cin >> t >> x >> y;
		scanf("%d %d %d", &t, &x, &y);
		if (t == 0) {
			in_ed[y].pb({x, i + 1});
			in_ed[x].pb({y, i + 1});
		} else {
			adj[x].pb(y);
		}
	}

	for (int i = 1; i <= N; i++) {
		adj[0].pb(i);
	}

	int id = 0;
	dfs(0, id);
	int ans = dfs2(0);

	vector<ii> v;
	if (ans) {
		// cout << "YES\n";
		printf("YES\n");
		for (int i = 1; i <= N; i++) {
			for (int u : adj[i]) {
				v.pb({i, u});
			}
			for (int u : ext[i]) {
				v.pb({i, u});
			}
		}

		// cout << (int)v.size() << endl;
		assert((int)v.size() == M);
		for (ii u : v) {
			// cout << u.fi << " " << u.se << '\n';
			printf("%d %d\n", u.fi, u.se);
		}
	} else {
		// cout << "NO\n";
		printf("NO\n");
	}
}
int T1;
int main() {
	// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	// cin >> T1;
	scanf("%d", &T1);
	while (T1--) {
		main1();
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+20);
        vector<int> un[n+20];
        vector<int> ne[n+20];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        map<int, int> done[n+10];
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);
                done[x][y] = 0;
                done[y][x] = 0;
            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                dobri.push(i);
        }
        int br = 0;
        while(!dobri.empty())
        {
            br++;
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x][tr] == 0)
                    {
                        done[x][tr] = 1;
                        done[tr][x] = 1;
                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        dobri.push(x);
                }
            }
        }

        if(br == n)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+20);
        vector<int> un[n+20];
        vector<int> ne[n+20];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        bool done[n+10];
        int q[n+10];
        for(int i = 1; i <= n; i++)
          {

            q[i] = 0; done[i]=false;}
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);

            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                {dobri.push(i); q[i] = 1;}
        }
        int br = 0;

        while(!dobri.empty())
        {
            br++;
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x]== false)
                    {

                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        if(q[x] != 1)
                            {dobri.push(x);q[x]=1;}
                }
            }
            done[tr]=true;
        }

        if(br == n)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+2);
        vector<int> un[n+2];
        vector<int> ne[n+2];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        bool done[n+10];
        int q[n+10];
        for(int i = 1; i <= n; i++)
          {

            q[i] = 0; done[i]=false;}
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);

            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                {dobri.push(i); q[i] = 1;}
        }
        int br = 0;

        while(!dobri.empty())
        {
            br++;
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x]== false)
                    {

                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        if(q[x] != 1)
                            {dobri.push(x);q[x]=1;}
                }
            }
            done[tr]=true;
        }

        if(br == n)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+20);
        vector<int> un[n+20];
        vector<int> ne[n+20];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        int done[n+10][n+10];
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);
                done[x][y] = 0;
                done[y][x] = 0;
            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                dobri.push(i);
        }

        while(!dobri.empty())
        {
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x][tr] == 0)
                    {
                        done[x][tr] = 1;
                        done[tr][x] = 1;
                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        dobri.push(x);
                }
            }
        }

        if(res.size() == m)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }

    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+20);
        vector<int> un[n+20];
        vector<int> ne[n+20];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        map<int, int> done[n+10];
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);
                done[x][y] = 0;
                done[y][x] = 0;
            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                dobri.push(i);
        }
        int br = 0;
        while(!dobri.empty())
        {
            br++;
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x][tr] == 0)
                    {
                        done[x][tr] = 1;
                        done[tr][x] = 1;
                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        dobri.push(x);
                }
            }
        }

        if(br == m)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+20);
        vector<int> un[n+20];
        vector<int> ne[n+20];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        int done[n+10][n+10];
        int q[n+10];
        for(int i = 1; i <= n; i++)
            q[i] = 0;
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);
                done[x][y] = 0;
                done[y][x] = 0;
            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                {dobri.push(i); q[i] = 1;}
        }
        int br = 0;

        while(!dobri.empty())
        {
            br++;
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x][tr] == 0)
                    {
                        done[x][tr] = 1;
                        done[tr][x] = 1;
                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        if(q[x] != 1)
                            {dobri.push(x);q[x]=1;}
                }
            }
        }

        if(br == n)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> {static_assert(D >= 1, "Vector dimension must be greater than zero!");template<typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}};template<typename T> struct Vec<1, T> : public vector<T> {
Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;for(auto p:s)a=a*10+p-'0';return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
    {
        queue<int> dobri;
        int n, m;
        cin >> n >> m;
        vector<int> in(n+20);
        vector<int> un[n+20];
        vector<int> ne[n+20];

        for(int i = 1; i <= n; i++)
            in[i] = 0;

        vector<pair<int,int>> res;
        map<int, int> done[n+10];
        int q[n+10];
        for(int i = 1; i <= n; i++)
        q[i] = 0;
        for(int i = 0 ; i < m; i++)
        {
            int t,x,y;
            cin >> t >> x >> y;
            if(t==0)
            {
                un[x].pb(y);
                un[y].pb(x);
                done[x][y] = 0;
                done[y][x] = 0;
            }
            else
            {
                res.pb({x , y});
                in[y]++;
                ne[x].pb(y);
            }
        }

        for(int i = 1; i <= n; i++)
        {
            if(in[i] == 0)
                {dobri.push(i); q[i] = 1;}
        }
        int br = 0;

        while(!dobri.empty())
        {
            br++;
            int tr = dobri.front();
            dobri.pop();

            if(in[tr] == 0)
            {
                for(int x : un[tr])
                {
                    if(done[x][tr] == 0)
                    {
                        done[x][tr] = 1;
                        done[tr][x] = 1;
                        ne[tr].pb(x);
                        in[x]++;
                        res.pb({tr, x});
                    }
                }
                for(int x : ne[tr])
                {
                    in[x]--;
                    if(in[x] == 0)
                        if(q[x] != 1)
                            dobri.push(x);
                }
            }
        }

        if(br == n)
        {
            cout << "YES" << endl;
            for(auto p : res)
            cout << p.first << " " << p.second << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}