#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



long long pow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n%i == 0LL) {
            res.push_back(i);
            long long temp = n/i;
            if (i != temp) res.push_back(temp);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int N;
long long a, b;

vll div1[20];
vll div2[20];

int main() {
    long long num = 1;
    for (int i = 1; i <= 16; ++i) {
        num *= 10;
        div1[i] = divisor(num);
        div2[i] = divisor(num-1);
        
        for (int j = 0; j < div1[i].size(); ++j) {
            //COUT(i); COUT(j);
            if ( (div1[i][j] & 1) || (div1[i][j] % (1LL<<i) == 0) ) continue;
            div1[i].erase(div1[i].begin() + j--);
        }
    }
    
    cin >> N;
    for (int id = 0; id < N; ++id) {
        cin >> a >> b;
        long long ten = pow(10LL, b);
        long long ano = pow(10LL, b) - 1;
        
        long long CA = pow(10LL, a-1);
        long long CB = pow(10LL, b-1);
        long long HI = pow(10LL, max(a+1, b+1));
        
        //COUT(a); COUT(b); COUT(div1); COUT(div2);
        
        vector<pll> res;
        for (int i = 0; i < div2[b].size(); ++i) {
            for (int j = 0; j < div1[b].size(); ++j) {
                long long p = div1[b][j] * div2[b][i];
                if (p > HI) break;
                if (p < CB*10-10) continue;
                
                long long q = (ten/div1[b][j]) * (ano/div2[b][i]);
                if (p < q) continue;
                
                long long A = (p + q + 1)/2 - ten;
                long long B = (p - q + 1)/2;
                
                //cout << p << ", " << q << " : " << A << ", " <<B << endl;
                
                if (A >= CA && A < CA * 10 && B >= CB && B < CB * 10) {
                    res.PB(pll(B, A));
                }
            }
        }
        sort(ALL(res));
        for (int i = 0; i < res.size(); ++i) {
            cout << res[i].second << " " << res[i].first << endl;
        }
        if (res.size() == 0) puts("No cats.");
    }
    return 0;
}


Measured memory_bytes: 1260