#include <bits/stdc++.h>
using namespace std;
struct p {
  long long int t, x, y;
} q[100005];
long long int a[100004], b[100005];
long long int fnc(long long int n) {
  long long int cnt = 0;
  return cnt;
}
int main() {
  long long int m, k;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int sum = 0;
    for (int i = 0; i * 7 <= n; i++) {
      long long int p = n - 7 * i;
      long long int m = p % 3;
      if (sum) break;
      for (int j = 1; j <= 15; j++) {
        if (m % 5 == 0 and m <= p) {
          cout << (p - m) / 3 << ' ' << m / 5 << ' ' << i << endl;
          sum = 1;
          break;
        }
        m += 3;
      }
    }
    if (sum == 0) cout << -1 << endl;
  }
}
