#include <bits/stdc++.h>
using namespace std;
char gap = 32;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  for (const auto &x : v) os << gap << x;
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << gap << p.second << ')';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    int n, i, j, k, x, y, z;
    cin >> n;
    x = n / 3;
    y = n / 5;
    z = n / 7;
    bool chk = true;
    for (i = 0; i <= x; i++) {
      for (j = 0; j <= y; j++) {
        for (k = 0; k <= z; k++) {
          if ((3 * i + 5 * j + 7 * k) == n) {
            cout << i << gap << j << gap << k;
            chk = false;
            break;
          }
        }
        if (!chk) break;
      }
      if (!chk) break;
    }
    if (chk) cout << "-1";
    cout << endl;
  }
}
