#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000000000000LL
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;

int main()
{
	int q;
	scanf("%d", &q);
	vector<ll> fib;
	fib.push_back(0);
	fib.push_back(1);
	while(fib.back()<=INF){
		int i=fib.size();
		fib.push_back(fib[i-1]+fib[i-2]);
	}
	int max=fib.size(); // max=89
	ll prod[100][100];
	for(int k=2; k<max; k++){
		for(int i=1; i<k; i++){
			prod[k][i]=fib[i]*fib[k-i];
		}
	}

	for(int i=0; i<q; i++){
		ll x, y;
		scanf("%lld %lld", &x, &y);
		if(x>y) swap(x, y);
		if(x==1){
			printf("%d %lld\n", 1, y%MOD);
			continue;
		}else if(x==2){
			if(y==2){
				printf("%d %d\n", 1, 4);
			}else{
				printf("%d %lld\n", 2, (y-1)/2%MOD);
			}
			continue;
		}
		int n1=upper_bound(fib.begin(), fib.end(), x)-fib.begin()-1;
		int n2=upper_bound(fib.begin(), fib.end(), y)-fib.begin()-1;
		int n=min(n1, n2-1);
		ll ans=0;
		ans+=((y-fib[n+1])/fib[n]+1);
		ans%=MOD;
		for(int i=1; i<n; i++){
			ll x1=fib[n]+prod[n][i], y1=fib[n+1]+prod[n+1][i+1];
			if(x1>x || y1>y) continue;
			ans+=((y-y1)/x1+1);
			ans%=MOD;
		}
		if(x<fib[n+1] || y<fib[n]){
			printf("%d %lld\n", n-1, ans);
			continue;
		}
		ans+=((x-fib[n+1])/fib[n]+1);
		ans%=MOD;
		for(int i=1; i<n; i++){
			ll x1=fib[n]+prod[n][i], y1=fib[n+1]+prod[n+1][i+1];
			if(x1>y || y1>x) continue;
			ans+=((x-y1)/x1+1);
			ans%=MOD;
		}
		printf("%d %lld\n", n-1, ans);
	}
	return 0;
}