#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define pll pair<ll,ll>
using namespace std;
ll f[105];
vector<pll> s[105];
void dfs(int x,ll a,ll b){
	if (x>88) return;
	if (a>=f[x]&&b>=f[x+1]) return;
	s[x].push_back(pll(a,b));
	dfs(x+1,b,b+a); dfs(x+1,b,b*2+a);
}
int main(){
	f[0]=f[1]=1;
	for (int i=2;i<=95;i++)
		f[i]=f[i-1]+f[i-2];
	dfs(1,1,1);
	int Q;
	scanf("%d",&Q);
	while (Q--){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if (x>y) swap(x,y);
		int ans=0; ll sum=0;
		for (int i=1;i<=100;i++)
			if (f[i]>x||f[i+1]>y){
				ans=i-1;
				break;
			}
		if (ans<=1){
			if (x==1) sum=y%mo;
			else if (x==2) sum=4;
			printf("1 %lld\n",sum);
			continue;
		}
		for (int i=0;i<s[ans].size();i++){
			pll p=s[ans][i];
			if (p.second<=x&&y>=p.first)
				sum=(sum+(y-p.first)/p.second)%mo;
			if (p.second<=y&&x>=p.first)
				sum=(sum+(x-p.first)/p.second)%mo;
		}
		printf("%d %lld\n",ans,sum);
	}
}