#include [[nodiscard]] static inline constexpr std::vector solve(const std::string& N) noexcept { constexpr std::array default_array = { INT_LEAST32_MAX, INT_LEAST32_MAX, INT_LEAST32_MAX, INT_LEAST32_MAX, INT_LEAST32_MAX, INT_LEAST32_MAX, INT_LEAST32_MAX, INT_LEAST32_MAX, }; std::vector> dp(N.size() + 1, default_array); dp[0][0] = 0; for (uint_fast32_t i = 0; i < N.size(); ++i) for (uint_fast32_t j = 0; j < 8; ++j) for (uint_fast32_t k = ((N[i] - '0') < j); k < UINT32_C(8); ++k) { const uint_fast32_t falling = k * 10 + (N[i] - '0') - j; dp[i + 1][j] = std::min(dp[i + 1][j], std::max(dp[i][k], falling / 8 + falling % 8)); } std::vector ans(dp[N.size()][0], 0); for (uint_fast32_t i = N.size(), j = 0, digit = 1; i != 0; --i, digit *= 10) { uint_fast32_t next_j = UINT_FAST32_MAX; for (uint_fast32_t k = ((N[i - 1] - '0') < j); k < UINT32_C(8); ++k) { const uint_fast32_t falling = k * 10 + (N[i - 1] - '0') - j; if (dp[i][j] == std::max(dp[i - 1][k], falling / 8 + falling % 8)) next_j = k; } const uint_fast32_t falling = next_j * 10 + (N[i - 1] - '0') - j; for (uint_fast32_t k = 0; k < falling / 8; ++k) ans[k] += 8 * digit; for (uint_fast32_t k = 0; k < falling % 8; ++k) ans[falling / 8 + k] += digit; j = next_j; } return ans; } static inline void output(const std::vector& ans) noexcept { std::cout << ans.size() << '\n'; for (const auto& res : ans) std::cout << res << '\n'; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t T; std::cin >> T; for (uint_fast32_t i = 0; i < T; ++i) { uint_fast32_t N; std::cin >> N; output(solve(std::to_string(81181819 - N))); } return 0; }