#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll proizcif(ll br){
    ll proiz=1;
    while(br>0){
        proiz*=br%10;
        br/=10;
    }
    return proiz;
}


int main(){
    ll t;
    cin >> t;
    for (int test=0; test<t; test++){
        ll n;
        cin >> n;
        vector<ll> c,f(n+1);
        c.push_back(0);
        f[0]=0;
        for (int i=1; i<=n; i++){
            ll pr=proizcif(i);
            sort(begin(c),end(c));
            if (binary_search(begin(c),end(c),pr)){
                //cout << "bs pronasao proizvod " << pr << endl;
                f[i]=f[i-1];
            }
            else{
                //cout << "bs nije pronasao proizvod " << pr << endl;
                c.push_back(pr);
                //cout << "dodat " << c[c.size()-1] << endl;
                f[i]=f[i-1]+1;
            }
            if (i==10){
                f[i]++;
            }
        }
        //cout << f[n] << endl;
        cout << "{";
        for (int i=0; i<f.size(); i++){
            cout << f[i] << ", ";
        }
        cout << "}";
    }
    return 0;
}