OI VIII - gol

// https://szkopul.edu.pl/problemset/problem/B8uHcsCWL_20NSJij1AL1b4C/site/?key=statement

#include <bits/stdc++.h>

// #define GARY_DBG
#define GARY_LIB

constexpr int sizik = 1000 * 1001;

#define ar std::array

typedef std::vector<std::vector<int>> _kra;
std::vector<int> V[47];
std::vector<int> P;

void print_ans(std::vector<int> v) {
    std::sort(v.begin(), v.end());
    std::cout << v.size() << '\n';
    for (const auto& a : v) {
        std::cout << a << " ";
    }
    std::cout << '\n';
}

void solve() {
    int n;
    std::cin >> n;

    if (10 <= n && n <= 46) {
        print_ans(V[n]);
        return;
    }

    int64_t M = 46;
    std::vector<int> st;
    for (const auto& p : P) {
        st.push_back(p);
        M += (int64_t)p;
        if ((int64_t)n <= M) break;
    }
    int nn = n;
    std::reverse(st.begin(), st.end());
    std::vector<int> ans;
    for (const auto& p : st) {
        if (nn - p >= 10) {
            ans.push_back(p);
            nn -= p;
        }
    }
    for (const auto& a : V[nn]) {
        ans.push_back(a);
    }
    print_ans(ans);
}

int32_t main() {
#ifndef GARY_DBG
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
#endif

    V[10] = {
        3,
        7,
    };
    V[11] = {11};
    V[29] = {
        5,
        7,
        17,
    };
    V[12] = {5, 7};
    V[30] = {
        13,
        17,
    };
    V[13] = {13};
    V[31] = {
        3,
        11,
        17,
    };
    V[14] = {3, 11};
    V[32] = {
        3,
        5,
        7,
        17,
    };
    V[15] = {3, 5, 7};
    V[33] = {
        5,
        11,
        17,
    };
    V[16] = {5, 11};
    V[34] = {
        3,
        7,
        11,
        13,
    };
    V[17] = {17};
    V[35] = {
        5,
        13,
        17,
    };
    V[18] = {5, 13};
    V[36] = {
        3,
        5,
        11,
        17,
    };
    V[19] = {3, 5, 11};
    V[37] = {
        7,
        13,
        17,
    };
    V[20] = {3, 17};
    V[38] = {
        3,
        5,
        13,
        17,
    };
    V[21] = {3, 5, 13};
    V[39] = {
        3, 5, 7, 11, 13,
    };
    V[22] = {5, 17};
    V[40] = {
        5,
        7,
        11,
        17,
    };
    V[23] = {5, 7, 11};
    V[41] = {
        11,
        13,
        17,
    };
    V[24] = {7, 17};
    V[42] = {5, 7, 13, 17};
    V[25] = {3, 5, 17};
    V[43] = {3, 5, 7, 11, 17};
    V[26] = {3, 5, 7, 11};
    V[44] = {3, 11, 13, 17};
    V[27] = {3, 7, 17};
    V[45] = {3, 5, 7, 13, 17};
    V[28] = {11, 17};
    V[46] = {5, 11, 13, 17};

    P = {37,     73,     139,     283,     569,     1129,    2267,     4523,     9049,     18097,     36191,     72383,     144773,
         289543, 579083, 1158161, 2316337, 4632673, 9265309, 18530639, 37061293, 74122571, 148245127, 296490277, 592980559, 1185961087};

    int t = 1;
    std::cin >> t;

    for (; t > 0; t--) {
        solve();
    }

    return 0;
}