#include <bits/stdc++.h>
using namespace std;
const long long inf = (1LL << 60) - 1;
const long long mxn = 1e9 + 5;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
map<string, long long> mp;
long long getprice(string a, string b) {
  if (!mp.count(a) || !mp.count(b)) return mxn;
  return mp[a] + mp[b];
}
void solve() {
  long long 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;
  } else {
    long long i = 1, m = 0, m1 = 0;
    while (n - 3 * i > 0) {
      if ((n - 3 * i) % 5 == 0) {
        m = (n - 3 * i) / 5;
        break;
      }
      if ((n - 3 * i) % 7 == 0) {
        m1 = (n - 3 * i) / 7;
        break;
      }
      i++;
    }
    if (m1 == 0 && m == 0)
      cout << -1 << "\n";
    else
      cout << i << " " << m << " " << m1 << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
