#include <bits/stdc++.h>
using namespace std;
void solve() {
  int i = 1, j, n, m;
  cin >> n;
  j = n % 7;
  int sev = 0, fiv = 0, thr = 0;
  sev = n / 7;
  if (n == 3) {
    thr++;
  } else if (n == 5) {
    fiv++;
  } else if (j % 3 == 0) {
    thr += j / 3;
  } else if (n >= 7) {
    if (j % 3 == 0) {
      thr += j / 3;
    } else if (j % 5 == 0)
      fiv += j / 5;
    else if (j == 4) {
      sev--;
      fiv++;
      thr += 2;
    } else if (j == 2) {
      sev--;
      thr += 3;
    } else if (j == 1) {
      sev--;
      thr++;
      fiv++;
    }
  } else
    i = -1;
  if (n == 0) i = 1;
  if (i == 1)
    cout << thr << " " << fiv << " " << sev << '\n';
  else
    cout << "-1\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
