#include int main() { int T; std::cin >> T; while (T--) { int64_t N; std::cin >> N; if (N % 8 > 0) { std::cout << -1 << std::endl; continue; } N /= 8; int64_t a = N / 1234; int64_t b = N / 1234; int64_t c = N / 1234; int64_t d = N / 1234; N %= 1234; if (N >= 1111) d++, N -= 1111; a += N / 123; b += N / 123; c += N / 123; N %= 123; if (N >= 111) c++, N -= 111; a += N / 12; b += N / 12; N %= 12; if (N >= 11) b++, N -= 11; a += N; int64_t total = a + b + c + d; for (int64_t v : {a, b, c, d}) { if (v * 2 >= total) a = -1; } if (a == -1) std::cout << -1 << std::endl; else std::cout << a << ' ' << b << ' ' << c << ' ' << d << std::endl; } }