#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

ll r(ll n) {
    ll x = sqrt(n);
    while (x * x > n) x--;
    while (x * x < n) x++;
    return x;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll t = 1, n, m, k, a, b, c, d, e, f, w, h, x1, x2, y2, l, z, arr[51][51] = {}, q;
    string s;
    //char x, y;
    cin >> t;
    while (t--) {
        cin >> n;
        if (n == 2) {
            cout << "0 0 1 1 0 0 0 0 0\n";
            continue;
        }
        ll chk = 0, c = r(n), j;
        for (ll i = 0; i < 10; i++, c++) {
            for (j = 0; j * 8 <= c * c - n && j <= n; j++) {
                if ((c * c - n - j * 8) % 3 == 0 && n - (c * c - n - j * 8) / 3 - j >= 0) {
                    chk = 1;
                    break;
                }
            }
            if (chk) {
                cout << n - (c * c - n - j * 8) / 3 - j << ' ' << (c * c - n - j * 8) / 3 << ' ' << j << " 0 0 0 0 0 0\n";
                break;
            }
        }
        if (!chk) cout << "-1\n";
    }

    return 0;
}