#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T &x){ cout << x << '\n';}
#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 REPS(i,n) FOR(i,1,n+1)
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
//Modulo Calculation
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

//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; }
    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(100, 1);
VV<P> worse(85);

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

int main(){
    ios;
    for(int i = 2; i < 100; i++) fib[i] = fib[i-1] + fib[i-2];
    worse[0].pb({1, 2}); 
    REP(i, 84){
        for(auto p:worse[i]){
            ll a = p.first, b = p.second, c = p.first + p.second;
            worse[i + 1].pb({b, c});
            if(fib[i + 2] == b and fib[i + 3] == c) worse[i + 1].pb({c, b + 2 * a});
        }
    }
    INT(q);
    while(q--) solve();
}

Measured memory_bytes: 4412