#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    bool f = false;
    long long x = -1;
    long long y = -1;
    long long z = -1;
    for (long long i = 0; i <= n / 3; i++) {
      for (long long j = 0; j <= n / 5; j++) {
        long long v = n - (3 * i + 5 * j);
        if (v >= 0 && v % 7 == 0 && !f) {
          f = true;
          x = i;
          y = j;
          z = v / 7;
        }
      }
    }
    if (f) {
      cout << x << " " << y << " " << z << "\n";
    } else {
      cout << -1 << "\n";
    }
  }
  return 0;
}
