#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline ll read(){
	ll n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int mo=1e9+7;
int Q,i,j,ans;
ll X,Y,inf=1e18+1,f[105];
struct ar{ll x,y;}now;
vector<ar>p[105];
int main(){
	f[0]=f[1]=1;
	fo(i,2,89) f[i]=f[i-1]+f[i-2];
	p[1].push_back((ar){1,2});
	p[1].push_back((ar){1,3});
	fo(i,1,86){
		for(j=0;j<p[i].size();j++) now=p[i][j],p[i+1].push_back((ar){now.y,now.y+now.x});
		now=p[i][0];
		p[i+1].push_back((ar){now.y,now.y*2+now.x});
	}
	Q=read();
	for(;Q--;){
		X=read(),Y=read();
		if (X>Y) swap(X,Y);
		ans=1;
		for(;f[ans+1]<=X&&f[ans+2]<=Y;ans++);
		printf("%d ",ans);
		if (ans==1){
			printf("%d\n",X*Y%mo);
			continue;
		}
		ans--;
		ll num=0;
		for(i=0;i<p[ans].size();i++){
			now=p[ans][i];
			if (now.y<=X) (num+=(Y-now.x)/now.y)%=mo;
			if (now.y<=Y) (num+=(X-now.x)/now.y)%=mo;
		}
		printf("%d\n",num);
	}
}