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

#pragma region Macros
#define Faster ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define m1 cout << -1 << endl
#pragma endregion

#pragma region Math
const ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#pragma endregion

void solve() {
    ll n;   cin>>n;
    ll l=n%10;
    int flag=1, cnt=0;
    while(n){
        if(n%10!=l){
            flag=0;
            break;
        }
        n/=10;
        cnt++;
    }
    if(!flag){
        cout<<0<<endl;
        return;
    }
    vector<string>v;
    for(int i=1;i<=cnt/2;i++){
            string s;
        if(cnt%i==0 and (cnt/i)%2==0){
            int p=cnt/i;
            p--;
            p/=2;
            int tr;
            for(int j=1;j<=p;j++){
                int tr=i;
                
                while(tr--) s+=to_string(l);
                tr=i;
                while(tr--) s+='0';
            }
             tr=i;
                while(tr--) s+=to_string(l);
        v.push_back(s);
        }
    }
    cout<<v.size()<<endl;
    
    sort(rall(v));
    for(auto x:v)
        cout<<x<<" ";
    cout<<endl;
}

int main() {
    Faster;
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}