#include "bits/stdc++.h"
using namespace std;

constexpr long long INF = 1000000000000000000, MOD = 1000000007;

int main() {
	vector<long long> Fib;
	Fib.push_back(1), Fib.push_back(1);
	while (1) {
		Fib.push_back(Fib[Fib.size() - 2] + Fib[Fib.size() - 1]);
		if (Fib[Fib.size() - 1] > INF) {
			Fib.pop_back();
			break;
		}
	}
	vector<vector<pair<long long, long long> > > Pair(Fib.size());
	Pair[1].push_back({ 1, 2 });
	for (int i = 1; i < Fib.size() - 1; i++) {
		for (int j = 0; j < Pair[i].size(); j++) {
			Pair[i + 1].push_back({ Pair[i][j].second, Pair[i][j].first + Pair[i][j].second });
		}
		Pair[i + 1].push_back({ Pair[i][0].first + Pair[i][0].second, Pair[i][0].first + Pair[i][0].first + Pair[i][0].second });
	}
	int Q;
	cin >> Q;
	for (int q = 0; q < Q; q++) {
		long long X, Y;
		cin >> X >> Y;
		if (X > Y) swap(X, Y);
		if (X == 1 || Y == 2) {
			cout << 1 << ' ' << (X * Y) % MOD << endl;
			continue;
		}
		int A = -1;
		for (int i = 0; ; i++) {
			if (Fib[i] <= X && Fib[i + 1] <= Y) A++;
			else break;
		}
		cout << A << ' ';
		long long B = 0;
		for (int i = 0; i < A; i++) {
			long long P = Pair[A][i].first, Q = Pair[A][i].second;
			if (P <= X) B += (Y - Q + P) / P, B %= MOD;
			if (Q <= X) B += (X - Q + P) / P, B %= MOD;
		}
		cout << B << endl;
	}
}
