#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define SZ(x) ((ll)(x).size())
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;

const int MOD = 1e9 + 7;
//ModInt
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(ll x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
  
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    ModInt &operator++ () { *this += 1; return *this;}
    ModInt operator++ (int) { *this += 1; return *this - 1;}
    ModInt &operator-- () { *this -= 1; return *this;}
    ModInt operator-- (int) { *this -= 1; return *this + 1;}
    bool operator==(ModInt rhs) const { return x == rhs.x; }    
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
  
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<MOD>;

using P = pair<ll,ll>;
V<> fib(90, 1);
VV<P> worst(85);

void preparation(){
    for(int i = 2; i < 90; i++) fib[i] = fib[i-1] + fib[i-2];
    worst[0].pb({1, 2}); 
    REP(i, 84){
        REP(j, SZ(worst[i])){
            P p = worst[i][j];
            ll a = p.first, b = p.second, c = a + b;
            worst[i + 1].pb({b, c});
            if(!j) worst[i + 1].pb({c, b + 2 * a});
        }
    }
}

void solve(){
    LL(x, y);
    if(x > y) swap(x, y);
    if(y <= 2){
        cout << 1 << " " << x * y << '\n';
        return;
    }
    ll a = 0;
    while(fib[a + 1] <= x and fib[a + 2] <= y) a++;
    cout << a << ' ';
    if(a == 1){
        cout << y % MOD << '\n';
        return;
    }
    mint res = 0;
    for(auto &p : worst[a - 1]){
        if(p.first > x or p.second > y) continue;
        res++;
        res += ((y - p.second) / p.first);
        if(p.second > x or p.first > y) continue;
        res++;
    }
    cout << res << '\n';
}

int main(){
    ios;
    preparation();
    INT(q);
    while(q--) solve();
}

Measured memory_bytes: 4448