/* Author : Nguyen Thanh Tung - Tran Hung Dao High School for Gifted Student */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ft first
#define sc second
#define ll long long
#define vll vector<ll>
#define vp vector<pll>
#define pll pair<ll, ll>
#define ull unsigned long long
#define FOR(i, l, r) for (ll i = (l); i <= (r); ++i)
#define FORD(i, r, l) for (ll i = (r); i >= (l); --i)
const long long maxn = 1e6 + 9;
const long long N = 3e4 + 9;
const long long oo = 1e18 + 9;
const long long INF = 0x3f;
const long long MOD = 1e9 + 7;
#define TASK "code"
void solve()
{
ll n;
cin >> n;
while (n--)
{
ll x;
cin >> x;
bool check = true;
FOR(i, 1, x - 3)
{
FOR(j, i + 1, x - 2)
{
FOR(k, j + 1, x - 1)
{
if (i * i * i + j * j * j + k * k * k == x * x * x)
{
cout << i << " " << j << " " << k << endl;
check = false;
break;
}
}
if (check == false)
{
break;
}
}
if (check == false)
{
break;
}
}
if (check)
{
cout << 0 << endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//freopen(TASK ".inp", "r", stdin);
//freopen(TASK ".out", "w", stdout);
solve();
return 0;
}
/// Stay calm, read the question slowly and understand the question, it is often simpler than you imagine
LyogQXV0aG9yIDogTmd1eWVuIFRoYW5oIFR1bmcgLSBUcmFuIEh1bmcgRGFvIEhpZ2ggU2Nob29sIGZvciBHaWZ0ZWQgU3R1ZGVudCAqLwoKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBlbmRsICdcbicKI2RlZmluZSBmdCBmaXJzdAojZGVmaW5lIHNjIHNlY29uZAojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHZsbCB2ZWN0b3I8bGw+CiNkZWZpbmUgdnAgdmVjdG9yPHBsbD4KI2RlZmluZSBwbGwgcGFpcjxsbCwgbGw+CiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIEZPUihpLCBsLCByKSBmb3IgKGxsIGkgPSAobCk7IGkgPD0gKHIpOyArK2kpCiNkZWZpbmUgRk9SRChpLCByLCBsKSBmb3IgKGxsIGkgPSAocik7IGkgPj0gKGwpOyAtLWkpCgpjb25zdCBsb25nIGxvbmcgbWF4biA9IDFlNiArIDk7CmNvbnN0IGxvbmcgbG9uZyBOID0gM2U0ICsgOTsKY29uc3QgbG9uZyBsb25nIG9vID0gMWUxOCArIDk7CmNvbnN0IGxvbmcgbG9uZyBJTkYgPSAweDNmOwpjb25zdCBsb25nIGxvbmcgTU9EID0gMWU5ICsgNzsKCiNkZWZpbmUgVEFTSyAiY29kZSIKCnZvaWQgc29sdmUoKQp7CiAgIGxsIG47CiAgIGNpbiA+PiBuOwogICB3aGlsZSAobi0tKQogICB7CiAgICAgIGxsIHg7CiAgICAgIGNpbiA+PiB4OwogICAgICBib29sIGNoZWNrID0gdHJ1ZTsKICAgICAgRk9SKGksIDEsIHggLSAzKQogICAgICB7CiAgICAgICAgIEZPUihqLCBpICsgMSwgeCAtIDIpCiAgICAgICAgIHsKICAgICAgICAgICAgRk9SKGssIGogKyAxLCB4IC0gMSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICBpZiAoaSAqIGkgKiBpICsgaiAqIGogKiBqICsgayAqIGsgKiBrID09IHggKiB4ICogeCkKICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICBjb3V0IDw8IGkgPDwgIiAiIDw8IGogPDwgIiAiIDw8IGsgPDwgZW5kbDsKICAgICAgICAgICAgICAgICAgY2hlY2sgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY2hlY2sgPT0gZmFsc2UpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICBpZiAoY2hlY2sgPT0gZmFsc2UpCiAgICAgICAgIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY2hlY2spCiAgICAgIHsKICAgICAgICAgY291dCA8PCAwIDw8IGVuZGw7CiAgICAgIH0KICAgfQp9CgppbnQgbWFpbigpCnsKICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSksIGNpbi50aWUoMCksIGNvdXQudGllKDApOwogICAvL2ZyZW9wZW4oVEFTSyAiLmlucCIsICJyIiwgc3RkaW4pOwogICAvL2ZyZW9wZW4oVEFTSyAiLm91dCIsICJ3Iiwgc3Rkb3V0KTsKICAgc29sdmUoKTsKICAgcmV0dXJuIDA7Cn0KLy8vIFN0YXkgY2FsbSwgcmVhZCB0aGUgcXVlc3Rpb24gc2xvd2x5IGFuZCB1bmRlcnN0YW5kIHRoZSBxdWVzdGlvbiwgaXQgaXMgb2Z0ZW4gc2ltcGxlciB0aGFuIHlvdSBpbWFnaW5l