#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; bool found = false; for (int x = 0; x * 1 <= N; x++) { if (found) break; for (int y = 0; x * 1 + y * 11 <= N; y++) { if ((N - x * 1 - y * 11) % 111 > 0) continue; int z = (N - x * 1 - y * 11) / 111; int64_t total = a + b + c + d + x + y + z; if ((a + x) * 2 >= total) continue; if ((b + y) * 2 >= total) continue; if ((c + z) * 2 >= total) continue; if (d * 2 >= total) continue; std::cout << a + x << ' ' << b + y << ' ' << c + z << ' ' << d << std::endl; found = true; break; } } if (!found) std::cout << -1 << std::endl; } }