#include<iostream>
#define m long long
using namespace std;
#define z else 
#define d(s,i,n) for(m i=s;i<n;i++)
m l[90],r[90],e[90][90],f[90][90];
int main(){m n;cin>>n;l[0]=1;r[0]=1;d(1,i,90)l[i]=r[i-1],r[i]=l[i-1]+r[i-1];d(0,i,89){e[i][0]=1,f[i][0]=1;d(1,j,90){if(i+1==j)f[i][j]=f[i][j-1]*2+e[i][j-1];z f[i][j]=f[i][j-1]+e[i][j-1];e[i][j]=f[i][j-1];}}d(0,i,n){m c,d;cin>>c>>d;if(d>c)swap(c,d);m k=0;d(0,j,90)if(c>=r[j]&&d>=l[j])k=j;m g;if(k==0)k=1,g=1;z if(k==1)if(d==1)g=c;z g=4;z{g=1;if(d>=r[k]&&c>=l[k]&&l[k]<r[k])g++;d(0,j,k)if(f[j][k]<=c&&e[j][k]<=d)g+=1+(c-f[j][k])/e[j][k];d(0,j,k)if(f[j][k]<=d)g+=1+(d-f[j][k])/e[j][k];}cout<<k<<" "<<g%1000000007<<endl;}}	
