#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n % 3 == 0) {
      cout << (n / 3) << " 0 0" << endl;
      continue;
    }
    if (n % 5 == 0) {
      cout << 0 << ' ' << (n / 5) << ' ' << 0 << endl;
      continue;
    }
    if (n % 7 == 0) {
      cout << "0 0 " << n / 7 << endl;
      continue;
    }
    bool f = 0;
    for (int i = 1;; i++) {
      int tmp = n - (3 * i);
      if (tmp < 0) break;
      if (tmp % 5 == 0) {
        cout << i << ' ' << tmp / 5 << ' ' << 0 << endl;
        f = 1;
        break;
      }
      if (tmp % 7 == 0) {
        cout << i << ' ' << 0 << ' ' << tmp / 7 << endl;
        f = 1;
        break;
      }
    }
    if (f) continue;
    for (int i = 1;; i++) {
      int tmp = n - (5 * i);
      if (tmp < 0) break;
      if (tmp % 7 == 0) {
        cout << 0 << ' ' << i << ' ' << tmp / 7 << endl;
        f = 1;
        break;
      }
    }
    if (f) continue;
    cout << -1 << endl;
  }
  return 0;
}
