#include <bits/stdc++.h>
using namespace std;
void route(int t) {
  long long n, i;
  while (t--) {
    cin >> n;
    long long cnt3 = 0, cnt5 = 0, cnt7 = 0;
    if (n % 3 == 0)
      cout << n / 3 << ' ' << "0 0\n";
    else if (n % 5 == 0)
      cout << "0 " << n / 5 << " 0\n";
    else if (n % 7 == 0)
      cout << "0 0 " << n / 7 << "\n";
    else {
      bool dtr = true;
      for (i = 1;; i++) {
        if ((n - (3 * i)) % 5 == 0) {
          cout << i << " " << (n - (3 * i)) / 5 << " 0\n";
          dtr = false;
          break;
        } else if ((n - (3 * i)) % 7 == 0) {
          cout << i << " "
               << "0 " << (n - (3 * i)) / 7 << "\n";
          dtr = false;
          break;
        } else if (i > n / 3)
          break;
      }
      if (dtr) cout << "-1\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  route(t);
  return 0;
}
