#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void sample() {}
long long int* read(long long int n) {
  long long int* arr = new long long int[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  return arr;
}
void solve() {
  long long int n, i, j, k, ans, m, o;
  cin >> n;
  long long int c3 = 0, c5 = 0, c7 = 0;
  for (i = 0; i < n; i++) {
    k = n - 3 * i;
    if (k < 0) {
      break;
    }
    for (j = 0; j < n; j++) {
      o = k - 5 * j;
      double r = o / (double)7;
      if (o < 0) {
        break;
      }
      if (ceil(r) == floor(r)) {
        cout << i << " " << j << " " << r << endl;
        return;
      }
    }
  }
  cout << -1 << endl;
  return;
}
int main() {
  fast();
  sample();
  long long int i, j, k, n, m, a, b, c, d, p, q, r, l, t = 1;
  long long int sum, count = 0, ans = 0;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
