#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
inline int add(int a, int b) {
  int ret = ((long long int)a + b) % mod;
  if (ret < 0) ret += mod;
  return ret;
}
inline int mul(int a, int b) {
  int ret = ((long long int)a * b) % mod;
  if (ret < 0) ret += mod;
  return ret;
}
template <typename... Args>
inline int add(int a, Args... args) {
  return add(a, add(args...));
}
template <typename... Args>
inline int mul(int a, Args... args) {
  return mul(a, mul(args...));
}
inline int addm(int a, int b, int MOD) {
  int ret = ((long long int)a + b) % MOD;
  if (ret < 0) ret += MOD;
  return ret;
}
inline int mulm(int a, int b, int MOD) {
  int ret = ((long long int)a * b) % MOD;
  if (ret < 0) ret += MOD;
  return ret;
}
inline int addm(int a, int b, int c, int MOD) {
  return addm(a, addm(b, c, MOD), MOD);
}
inline int mulm(int a, int b, int c, int MOD) {
  return mulm(a, mulm(b, c, MOD), MOD);
}
template <typename T>
void show2d(const vector<vector<T>>& adj) {
  for (auto x : adj) {
    for (auto y : x) {
      cout << y << " ";
    }
    cout << "\n";
  }
}
long long int modexp(long long int a, long long int b, long long int mod) {
  long long int x = 1;
  while (b) {
    if (b & 1) x = ((x % mod) * (a % mod)) % mod;
    a = ((a % mod) * (a % mod)) % mod;
    b = b / 2;
  }
  return x;
}
bool ispalindrome(long long int n) {
  long long int rev = 0, n1 = n;
  while (n1 > 0) {
    rev = rev * 10 + n1 % 10;
    n1 /= 10;
  }
  return (n == rev);
}
void rf() {}
void solve() {
  int n;
  cin >> n;
  if (n % 3 == 0) {
    cout << n / 3 << " " << 0 << " " << 0 << "\n";
    return;
  }
  if (n % 5 == 0) {
    cout << 0 << " " << n / 5 << " " << 0 << "\n";
    return;
  }
  if (n % 7 == 0) {
    cout << 0 << " " << 0 << " " << n / 7 << "\n";
    return;
  }
  if (n == 1 || n == 2 || n == 4) {
    cout << -1 << "\n";
    return;
  }
  if (n == 8) {
    cout << 1 << " " << 1 << " " << 0 << "\n";
    return;
  }
  int nn = n - n % 10;
  int nnn = n % 10;
  if (nnn == 1 || nnn == 4 || nnn == 7) {
    nn -= 5;
    nnn += 5;
  } else if (nnn == 2 || nnn == 8) {
    nn -= 10;
    nnn += 10;
  }
  cout << nnn / 3 << " " << nn / 5 << " " << 0 << "\n";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
