#include <iostream>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        int a,b;
        cin>>a>>b;
        int m,n;
        int r=2;
        int br=1;
        int k=a;
        int d=k%r;
        while(d != 0)
        {
            r+=1;
            d=k%r;
        }
        n=r;
        m=k/n;
        cout<<n<< " " <<m<<endl;
    }
    return 0;
}