//Created Time:2019/12/9 8:57:49
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define mod 1000000007
#define ll long long

using namespace std;

ll f[100];

void init();
void work(ll, ll);
int calc(ll, ll, ll, ll);
ll read();

int main(){
	init(); int t; cin >> t;
	while(t--){
		ll x = read(), y = read();
		if(x > y) swap(x, y); work(x, y);
	}
	return 0;
}

void init(){
	f[1] = 1;
	for(int i = 2; i <= 88; ++i)
		f[i] = f[i - 1] + f[i - 2];
	return ;
}

int calc(ll x, ll y, ll a, ll b){
	int ans = ((y - b) / a + 1) % mod;
	if(b <= x) (ans += ((y - a) / b + 1) % mod) %= mod;
	return ans;
}

void work(ll x, ll y){
	if(x == 1){
		printf("%d %d\n", 1, y % mod);
		return ;
	}
	if(x == 2 && y == 2){
		puts("1 4");
		return ;
	}
	int pos = upper_bound(f + 1, f + 89, x) - f - 1;
	if(f[pos + 1] > y) --pos; printf("%d ", pos - 1);
	ll a = f[pos], b = f[pos + 1];
	int ans = calc(x, y, a, b);
	for(int i = 2; i < pos; ++i){
		ll na = a + f[pos - i] * f[i], nb = b + f[pos - i + 1] * f[i];
		if(na < a || nb < b || na > x || nb > y) continue;
		(ans += calc(x, y, na, nb)) %= mod;
	}
	printf("%d\n", ans);
	return ;
}

ll read(){
	ll x = 0; char ch = getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	return x;
}